烦人的是我的登录检查脚本没有重定向到我告诉它的地方。 我知道它正确地打if语句,因为我把回声检查它。 这是公然跳到标题,因为在第一种情况下,它回声“ - 空白”,因为它应该也是“它甚至得到这么远?”标题位置不工作 - 但肯定是通过
所以在这个基础上,我知道它打到头 - 它只是简单地忽略它,我不能为我的生活摸索为什么。
林肯定它的简单,我错过了一些荒谬明显的东西,但我只是不能看到它。 有什么建议吗?
// makes sure they filled it in
if($_POST['frmLogin-username'] == "" || $_POST['frmLogin-password'] == ""){
echo " - blanks";
header('Location: ?page=landing&action=login&message=1');
echo "Did it even get this far?";
die;
}
else{
// checks it against the database
$query = mysql_query("SELECT * FROM shops WHERE shopUsername = '".$_POST['frmLogin-username']."'");
//Gives error if user dosen't exist
$count = mysql_num_rows($query);
if ($count == "0"){
echo " - no user";
header('Location: ?page=landing&action=login&message=2');
die;
}
else{
while($row = mysql_fetch_array($query)){
//gives error if the password is wrong
if ($_POST['frmLogin-password'] != $row['shopPassword']){
echo " - wrong pass";
header('Location: ?page=landing&action=login&message=3');
die;
}
else{
// if login is ok then we add a cookie
$hour = time() + 3600;
setcookie(shopusername, $_POST['frmLogin-username'], $hour);
setcookie(shopid, $row['shopId'], $hour);
//then redirect them to the shop panel
header("Location: ?page=shop");
die;
}
}
}
}
编辑:这个问题是我有通过调用加载的index.php内我的所有网页的方式做包括我现在正在研究 我纷纷出招这个过程页面到它自己的PHP文件,它现在的作品很好
你可以发送文本内容到浏览器后不发送标题 - 任何回声或空白都将阻止页面重定向。 – 2012-03-29 20:08:59
此外,根据HTTP规范,您必须提供完整的URI到位置,而不是相对路径。 (虽然这可能不是问题,因为任何现代浏览器都可以容忍这个问题。) – Corbin 2012-03-29 20:10:12
回声通常不存在 - 它们被添加用于测试 – TomK89 2012-03-29 20:13:26