php - isset 按钮
我尝试解决问题但没有成功。我从谷歌分析检索数据,我必须发送开始和结束日期。我有两个文本框,用户选择开始和结束日期。但是,但在用户选择 开始和结束日期之前。问题出现了..
我使用isset的地方在这里,
这是我的完整html
<?php
define('ga_email','[email protected]');
define('ga_password','************');
define('ga_profile_id','*******');
require 'gapi.class.php';
require 'connectDB.php';
$ga = new gapi(ga_email,ga_password);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>İçerik</title>
<script language="javascript" type="text/javascript" src="datetimepicker.js">
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
//For this script, visit http://www.javascriptkit.com
</script>
</head>
<div></div>
<body>
<table align="center">
<tr>
<td><br />
<br />
<form action="#" method="post" name="formDates" id="form1" >
<table width="303" height="40" border="0" align="center">
<table width =""
<tr>
<td>Başlangıç Tarihi</td>
<td>
<label for="txtStartDate"></label>
<input type="text" name="txtStartDate" id="txt1" value="" /><a href="javascript:NewCal('txt1','ddmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Başlangıç Tarihi Seçin">
</a>
</td>
</tr>
<tr>
<td>Bitiş Tarihi</td>
<td>
<label for="txtEndDate"></label>
<input type="text" name="txtEndDate" id="txt2" /><a href="javascript:NewCal('txt2','ddmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Bitiş Tarihi Seçin">
</a>
</td>
</tr>
</form>
<tr>
<td><input type="submit" name="btnSubmit" value="Gönder"</td>
</tr>
</table>
<table width="1250" height="26" align="center">
<tr>
<td width="138"><strong>Kanal Adı</strong>
<td width="150"><b>Kategori Adı</b></td>
<td width="130"><p><strong>Event Adı</strong></td>
<td width="145"><strong>Toplam</strong>
</tr>
</table>
<?php
if(isset($_POST['submit'])){
$startDate = $_POST['txtStartDate'];
$endDate = $_POST['txtEndDate'];
}
$arrDates = explode("-",$startDate);
$startDate=$arrDates[2]."-".$arrDates[1]."-".$arrDates[0];
$arrDates = explode("-",$endDate);
$endDate = $arrDates[2]."-".$arrDates[1]."-".$arrDates[0];
echo $startDate;
echo $endDate;
$ga->requestReportData(ga_profile_id,array('eventCategory','eventAction'),array('totalEvents'),$sort_metric=null,$filter='eventAction==InitPlayer',$start_date='2012-02-02',$end_date='2012-02-16');
foreach($ga->getResults() as $result2);
{
echo $result2->geteventCategory();
echo $result2->geteventAction();
echo $result2->gettotalEvents();
}
$ga->requestAccountData();
$mysql = new mysql();
$mysql->connect();
$counter = 0;
foreach($ga->getResults() as $result)
{
echo $result . ' (' . $result->getProfileId() . ")<br />";
echo "<br />";
$counter++;
}
$result = mysql_query("select profile_id from profiles");
$num_rows = mysql_num_rows($result);
if($counter != $num_rows)
{
$mysql->query("delete from profiles");
foreach($ga->getResults() as $result)
{
$mysql->query("insert into profiles values(".$result->getProfileId().",'".$result."')");
}
}
?>
</td>
</tr>
</table>
</body>
</head>
</html>
有什么问题吗?
如果解决了选择开始和结束日期的问题,则问题会在我选择之前发生
i try to solve a problem but didnt succeed. I retrieve datas from google analytics and i have to send start and end date. I have two textbox and user select start and end date.However, but before user select start and end date. The problem occurs..
The place that i use isset is here,
This is my full html
<?php
define('ga_email','[email protected]');
define('ga_password','************');
define('ga_profile_id','*******');
require 'gapi.class.php';
require 'connectDB.php';
$ga = new gapi(ga_email,ga_password);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>İçerik</title>
<script language="javascript" type="text/javascript" src="datetimepicker.js">
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
//For this script, visit http://www.javascriptkit.com
</script>
</head>
<div></div>
<body>
<table align="center">
<tr>
<td><br />
<br />
<form action="#" method="post" name="formDates" id="form1" >
<table width="303" height="40" border="0" align="center">
<table width =""
<tr>
<td>Başlangıç Tarihi</td>
<td>
<label for="txtStartDate"></label>
<input type="text" name="txtStartDate" id="txt1" value="" /><a href="javascript:NewCal('txt1','ddmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Başlangıç Tarihi Seçin">
</a>
</td>
</tr>
<tr>
<td>Bitiş Tarihi</td>
<td>
<label for="txtEndDate"></label>
<input type="text" name="txtEndDate" id="txt2" /><a href="javascript:NewCal('txt2','ddmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Bitiş Tarihi Seçin">
</a>
</td>
</tr>
</form>
<tr>
<td><input type="submit" name="btnSubmit" value="Gönder"</td>
</tr>
</table>
<table width="1250" height="26" align="center">
<tr>
<td width="138"><strong>Kanal Adı</strong>
<td width="150"><b>Kategori Adı</b></td>
<td width="130"><p><strong>Event Adı</strong></td>
<td width="145"><strong>Toplam</strong>
</tr>
</table>
<?php
if(isset($_POST['submit'])){
$startDate = $_POST['txtStartDate'];
$endDate = $_POST['txtEndDate'];
}
$arrDates = explode("-",$startDate);
$startDate=$arrDates[2]."-".$arrDates[1]."-".$arrDates[0];
$arrDates = explode("-",$endDate);
$endDate = $arrDates[2]."-".$arrDates[1]."-".$arrDates[0];
echo $startDate;
echo $endDate;
$ga->requestReportData(ga_profile_id,array('eventCategory','eventAction'),array('totalEvents'),$sort_metric=null,$filter='eventAction==InitPlayer',$start_date='2012-02-02',$end_date='2012-02-16');
foreach($ga->getResults() as $result2);
{
echo $result2->geteventCategory();
echo $result2->geteventAction();
echo $result2->gettotalEvents();
}
$ga->requestAccountData();
$mysql = new mysql();
$mysql->connect();
$counter = 0;
foreach($ga->getResults() as $result)
{
echo $result . ' (' . $result->getProfileId() . ")<br />";
echo "<br />";
$counter++;
}
$result = mysql_query("select profile_id from profiles");
$num_rows = mysql_num_rows($result);
if($counter != $num_rows)
{
$mysql->query("delete from profiles");
foreach($ga->getResults() as $result)
{
$mysql->query("insert into profiles values(".$result->getProfileId().",'".$result."')");
}
}
?>
</td>
</tr>
</table>
</body>
</head>
</html>
what is wrong?
if a choose start and end date problems is solved , problems occurs before that i choose
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
它必须是
isset($_POST["btnSubmit"])
不是提交Submit = type
btnSubmit = 按钮的名称
It must be
isset($_POST["btnSubmit"])
NOT submitsubmit = type
btnSubmit = name of the button
我觉得应该是:
而不是:
isset前面的感叹号表示
not
。另外,我会检查您想要使用的实际字段,而不是$_POST['submit']
:您收到错误的原因是
$_POST['submit']< /代码> 不存在。不存在带有名为
submit
的name
属性的input
元素。请注意type
和name
之间的区别。I think it should be:
instead of:
The exclamation mark in front of
isset
meansnot
. Also I would check for the actual fields you want to use, not for$_POST['submit']
:The reason you were getting the error is that
$_POST['submit']
does not exist. There is notinput
element with aname
attribute calledsubmit
. Beware of the difference betweentype
andname
.您的表单似乎与您在此 php 文件中使用的表单不符合相同的变量名称规范。确保表单中的字段名称与此处的字段名称匹配。
提交成功后,您还应该在 php 文件中进行这些检查:
if(!isset($_POST['submit']))
It seems that your form may not be conforming to the same variable name specification with the one that you use in this php file. Make sure field names are matching within the form and here.
And also you should make these checks in your php file after submission success:
if(!isset($_POST['submit']))
当您的页面正在加载且未设置
$_POST['submit']
时,您的$_POST['txtStartDate']
和$_POST['txtEndDate']
未设置,因此$arrDates
也未设置。您需要检查这些 $_POST 变量是否已设置才能使用它们。When your page is loading and
$_POST['submit']
is not set, your$_POST['txtStartDate']
and$_POST['txtEndDate']
are not set so$arrDates
is not set too. You need to check if these $_POST vars are set or not, to work with them.您必须对每个变量使用
isset()
,而不仅仅是一个变量。$_POST['txtStartDate']
和$_POST['txtEndDate']
以及其他变量根本没有定义,这意味着它们没有随POST 一起发送请求。
You have to use
isset()
on every variable, not just one variable.$_POST['txtStartDate']
and$_POST['txtEndDate']
and other variables are simply not defined, this means that they were not sent with thePOST
request.我想应该是
if(isset($_POST['submit']))
而不是if(!isset($_POST['submit']))
作为 < code>! 开头表示否定I guess it should be
if(isset($_POST['submit']))
instead ofif(!isset($_POST['submit']))
as!
in the start means a negation这意味着如果未按下提交按钮。您应该检查
$_POST['submit']
是否已设置(作为表单提交的结果),如下所示:This means that if the submit button was NOT pressed. You should check if the
$_POST['submit']
is set, as a result of the form submission, like so: