0
我有一個登錄腳本,當窗體重定向它只是顯示一個空白屏幕,任何想法?我對PHP很陌生,所以對腳本的任何評論都會很棒。登錄腳本給空白屏幕
非常感謝您的幫助!
<?php
session_start(); //must call session_start before using any $_SESSION variables
$username = $_POST['username'];
$password = $_POST['password'];
//connect to the database here
require_once('../Connections/PropSuite.php');
mysql_select_db($database_PropSuite, $PropSuite);
$username = mysql_real_escape_string($username);
$query = "SELECT password, salt
FROM users
WHERE username = '$username';";
$result = mysql_query($query);
if(mysql_num_rows($result) < 1) //no such user exists
{
header('Location: index.php');
die();
}
$userData = mysql_fetch_array($result, MYSQL_ASSOC);
$hash = hash('sha256', $userData['salt'] . hash('sha256', $password));
if($hash != $userData['password']) //incorrect password
{
header('Location: index.php');
die();
}
else
{
validateUser(); //sets the session data for this user
}
//redirect to another page or display "login success" message
?>
如果登錄的數據實際上是正確的,會發生什麼?在這種情況下,我看不到重定向(除非它在validateUser中) – mboldt
您是否檢查過日誌? –
哦,很多人會告訴你使用PDO :-) http://us.php.net/pdo – mboldt