你好,我對PHP很陌生,所以不要打擾我,但我無法弄清楚這個代碼有什麼問題。所以基本上我有幾種形式的輸出,但只要我用mysql做任何事情(即使只是連接和斷開!),它也不會允許我做任何類型的輸出。它也不會讓我重定向。Mysql調用會停止所有形式的輸出php
我試圖把mysql連接和斷開連接代碼之間的所有代碼都取出來,但它並沒有幫助解決任何問題,但是,只要我註釋掉mysql連接代碼,我的所有輸出和重定向就可以工作!我試圖建立一個簡單的登錄腳本,從其他地方的表單獲取電子郵件和密碼。我很想解決這個問題,所以我可以弄清楚它的其餘部分是否有效。我知道'header'在echo
之後不起作用;回聲和文件寫入將不會在那裏,只要我可以確保這是工作。任何幫助,將不勝感激!謝謝!
<?php
/*
Login.php searches for the email address given by loginPage.php in the data base.
If the email is found and the password given by loginPage.php matches that stored
in the data base, a session will begin and the client will be redirected to the
main page.
*** INCOMPLETE ***
*/
echo "HELLO!";
$email = $_POST["email"];
$password = $_POST["password"];
$errorLog = fopen("login.txt", "w");
fwrite($errorLog, "***Sesion started***");
$mysql_id = mysql_connect("localhost", "root", "12131");
if (!$mysql_id)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('informationStation', $mysql_id);
$results = mysql_query("SELECT password FROM Personals WHERE email = '" . $email . "';", $mysql_id);
if($results != null && $password == mysql_fetch_array($result))
{
$redirect = 'Location: http://127.0.1.1/main.php';
}
else
{
$redirect = 'Location: http://127.0.1.1/loginPage.php';
{
mysql_close($mysql_id);
fwrite($errorLog, "result: " . $results);
fwrite($errorLog, "redirect: " . $redirect);
fclose($errorLog);
header($redirect);
?>
檢查你的服務器/ php錯誤日誌,看看是否有什麼崩潰,並打開所有的PHP調試選項:display_error,error_log等...不要在黑暗中工作,打開所有可用的燈。 – 2012-08-02 15:38:58
告訴我們你寫的代碼,也許我們可以幫你 – 2012-08-02 15:39:53