我有这样的密码
第一个循环计数了多少个后数组:
for($i = 0; $i < $jumlah_qty ;$i++) {
if(!empty($qty[$i]) && !empty($id_cat[$i])) {插入预订:
$insert_booking_hd = $user_class->select($az);
$id_cates = $id_cat[$i];
for($b = 0;$b<$qty[$i];$b++) {如果设置了$_POST[$id_cates),首先进行验证,运行以下代码:
if(isset($_POST[$id_cates."".$b])){
$id_seat = $_POST[$id_cates."".$b];在$select_seat中查找座位号,并在$seat_number中查找是否存在座位号:
$select_seat = $user_class->select($query);
$seat_number = $user_class->select($querys);
$row_seat = $user_class->numrows($select_seat);
$row_seat2 = $user_class->numrows($seat_number);
if($row_seat>0) {
$update_seat = $user_class->update($update_false);
$bol[$b] = FALSE;
} else {
if( $row_seat2>0 ) {
$insert_booking_dt = $user_class->insert($insert);
$update_seat = $user_class->update($update_true);
$bol[$b] = TRUE;
} else {
$bol[$b] = FALSE;
}
}
} else {
$insert_booking_dt = $user_class->insert($insert_without_seat);
$bol[$b] = TRUE;
}
if($bol[$b]) {
echo "FALSE";
header("location:../../../print.php?id=$id_booking");
}
else {
echo "WRONG";
header("location:../../../event.php?msg=Same seat number");
}
}
}
}我的php验证有什么问题吗?
因为如果我输入$id_seat数组,它总是会重定向到print.php,尽管验证是假的。
例如,如果我输入3个数组,然后我回显假错误假
仍然重定向到print.php而不是event.php
如果数组之一出错,然后重定向到event.php,我如何读取?
发布于 2013-07-27 10:37:16
如果数组的之一出错,然后重定向到event.php,我如何读取?
你可以从break循环中解脱出来.
而不是:
else {
echo "WRONG";
header("location:../../../event.php?msg=Same seat number");
}你可以试试:
else {
echo "WRONG";
header("location:../../../event.php?msg=Same seat number");
break 2;
} https://stackoverflow.com/questions/17896579
复制相似问题