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


?>
4

2 に答える 2

0

validateUser()関数にリダイレクトがない限り、リダイレクトが欠落していると思います。そうでない場合は、次のいずれかを実行できます。

else
{
   validateUser(); //sets the session data for this user
}
//redirect to another page or display "login success" message
header('Location: your-desired-login-location.php');
die();
?>

また..

else
{
   validateUser(); //sets the session data for this user
   header('Location: your-desired-login-location.php');
   die();
}
//redirect to another page or display "login success" message

?>
于 2012-10-22T20:15:26.037 に答える
0

コードに解析エラーがあり、エラー報告がオフになっている可能性があります。

解決:

これをヘッダーに入れてエラーを確認し、修正してください。完了したらこれを削除します。本番環境では不要です。

error_reporting(E_ALL & ~E_NOTICE);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
于 2012-10-22T19:28:26.773 に答える