以下是 header.php 的开头,这是一个包含在我所有页面顶部的文件。就像现在一样,它包含的每个页面在浏览器中都是空白的——我做错了什么?(这里用 x:es 替换的数据库登录凭据是正确的。)
session_start();
if (isset($_POST['log_out'])) {
session_unset();
session_destroy();
$_SESSION = array();
}
if (isset($_POST['username']) && isset($_POST['password'])) {
$salt1 = "ghjfdghpuaqXC"
$salt2 = "GHLUYKRGrtuuh"
$password = sha1($salt1 . $_POST['password'] . $salt2);
$db_hostname = 'xxxxxxxx';
$db_username = 'xxxxxxxx';
$db_password = 'xxxxxxxx';
$db_database = 'xxxxxxxx';
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());
mysql_select_db($db_database)
or die("Unable to select database: " . mysql_error());
$query = "SELECT password FROM users WHERE name = '" . $_POST['username'] . "'";
$passwordindatabase = mysql_query($query);
if ($password == $passwordindatabase) {
$_SESSION['logged_in'] = true;
$_SESSION['user'] = $_POST['username'];
unset($_POST['username']);
unset($_POST['password']);
}
}