-4

我有这个未定义的偏移量,似乎无法找出原因。当它拒绝虚假表格时,它正在重定向它的位置。请帮忙。

这是播放下面三行的区域。

if ($_POST['FirstName'] == "" || $_POST['LastName'] == "" ||  $_POST['Email'==""] ||                 
  $_POST['Phone'==""] || $_POST['Mobile'==""] || $_POST['Address'==""] ||
  $_POST['City'==""] || $_POST['Town'==""] || $_POST['Country'==""] ){


     $redirect= sprintf("order.php?error=true&name=%s", $_SESSION['order']['product']);
     if (!$_COOKIE['PHPSESSID']) { 
       $redirect .= '&'.SID ;
     }
       header(sprintf("Location: %s", $redirect));
       exit; 

     }
4

3 回答 3

6

这个:

$_POST['Email'==""]

应该:

$_POST['Email'] == ""

对于所有其他领域也是如此。

于 2013-07-17T07:41:27.733 回答
3

这可能是因为您的]右括号未对齐。那是,

$_POST['Address'==""]

应该

$_POST['Address']==""
于 2013-07-17T07:41:39.507 回答
2

代替

if ($_POST['FirstName'] == "" || $_POST['LastName'] == "" ||  $_POST['Email'==""] ||                 
  $_POST['Phone'==""] || $_POST['Mobile'==""] || $_POST['Address'==""] ||
  $_POST['City'==""] || $_POST['Town'==""] || $_POST['Country'==""] ){

if ($_POST['FirstName'] == "" || $_POST['LastName'] == "" ||  $_POST['Email'] == "" ||                 
  $_POST['Phone'] == "" || $_POST['Mobile'] == "" || $_POST['Address'] == "" ||
  $_POST['City'] == "" || $_POST['Town'] == "" || $_POST['Country'] == "" ){

在你有之前注意,$_POST['Email'==""]而不是$_POST['Email'] == ""

在检查它们是否为空之前,您还应该使用isset()检查它们是否已设置。

于 2013-07-17T07:42:36.643 回答