php - isset 按钮

发布于 2025-01-06 20:56:03 字数 4762 浏览 0 评论 0原文

我尝试解决问题但没有成功。我从谷歌分析检索数据,我必须发送开始和结束日期。我有两个文本框,用户选择开始和结束日期。但是,但在用户选择 在此处输入图像描述开始和结束日期之前。问题出现了..

我使用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 enter image description herestart 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

深海里的那抹蓝 2025-01-13 20:56:03

它必须是 isset($_POST["btnSubmit"]) 不是提交

Submit = type
btnSubmit = 按钮的名称

It must be isset($_POST["btnSubmit"]) NOT submit

submit = type
btnSubmit = name of the button

荭秂 2025-01-13 20:56:03

我觉得应该是:

if(isset($_POST['submit']))

而不是:

if(!isset($_POST['submit']))

isset前面的感叹号表示not。另外,我会检查您想要使用的实际字段,而不是 $_POST['submit']

if(isset($_POST['txtStartDate']) && isset($_POST['txtEndDate']))
{
    // Do something with $_POST['txtStartDate'] and $_POST['txtEndDate']
}

您收到错误的原因是 $_POST['submit']< /代码> 不存在。不存在带有名为 submitname 属性的 input 元素。请注意 typename 之间的区别。

I think it should be:

if(isset($_POST['submit']))

instead of:

if(!isset($_POST['submit']))

The exclamation mark in front of isset means not. Also I would check for the actual fields you want to use, not for $_POST['submit']:

if(isset($_POST['txtStartDate']) && isset($_POST['txtEndDate']))
{
    // Do something with $_POST['txtStartDate'] and $_POST['txtEndDate']
}

The reason you were getting the error is that $_POST['submit'] does not exist. There is not input element with a name attribute called submit. Beware of the difference between type and name.

青巷忧颜 2025-01-13 20:56:03
Undefined index txtStartDate, ...

您的表单似乎与您在此 php 文件中使用的表单不​​符合相同的变量名称规范。确保表单中的字段名称与此处的字段名称匹配。

提交成功后,您还应该在 php 文件中进行这些检查: if(!isset($_POST['submit']))

Undefined index txtStartDate, ...

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']))

幻想少年梦 2025-01-13 20:56:03

当您的页面正在加载且未设置 $_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.

放低过去 2025-01-13 20:56:03

您必须对每个变量使用 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 the POST request.

提赋 2025-01-13 20:56:03

我想应该是 if(isset($_POST['submit'])) 而不是 if(!isset($_POST['submit'])) 作为 < code>! 开头表示否定

I guess it should be if(isset($_POST['submit'])) instead of if(!isset($_POST['submit'])) as ! in the start means a negation

抱着落日 2025-01-13 20:56:03
if(!isset($_POST['submit']))

这意味着如果按下提交按钮。您应该检查 $_POST['submit'] 是否已设置(作为表单提交的结果),如下所示:

if(isset($_POST['submit']))
if(!isset($_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:

if(isset($_POST['submit']))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文