【发布时间】:2011-06-08 07:25:42
【问题描述】:
代码如下:
<?php
$curDate = date("r",strtotime("now"));
if($database->addNewSale($_SESSION['username'],$_SESSION['userid'], $_SESSION['cart'],$curDate) ==10){
//Some of the offers in the cart have expired and cannot be purchased!
header("Location: ../order/index.php");
exit;
} else if($database->addNewSale($_SESSION['username'],$_SESSION['userid'], $_SESSION['cart'],$curDate)){
echo "insert process ok";
}
else echo "sale has not been saved into the db";
?>
但是,当addNewSale函数返回10是购物车错误的代码时,redirect header函数实际上并没有重定向到我设置的页面。
【问题讨论】:
-
<?php标签之前的空格是您在此处写的,还是实际上也在您的页面中?有什么错误吗? (你设置了什么error_reporting级别?) -
它会重定向吗?它会进入哪个页面?是否有可能 ../order/index.php 不存在,而您又被退回到 404 页面?
-
@george 这是在上课吗?就像您将功能视为方法一样
-
好吧,这很奇怪:在我的 MAMP localhost 服务器上,它不会重定向。我在笔记本电脑的 WAMP localhost 上尝试过它,它可以工作!!我不知道发生了什么!
-
顺便说一句,我没有收到任何警告或错误。