煩人的是我的登錄檢查腳本沒有重定向到我告訴它的地方。 我知道它正確地打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