我的登錄頁面並未將我重定向到下一個網頁,即使我輸入了正確的用戶名和密碼數據。數據庫未從mysql數據庫中讀取
當我檢查config.inc,並使其到config.php文件
它不顯示在網頁上的任何東西。
任何建議
CONFIG.INC
$con=mysqli_connect("localhost","[email protected]","","test");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
LOGINPROC PAGE
<?php
// Inialize session
session_start();
// Include database connection settings
include('config.inc');
// Retrieve username and password from database according to user's input
$login = mysql_query("SELECT * FROM users WHERE (username = '" . mysql_real_escape_string($_POST['username']) . "') and (password = '" . mysql_real_escape_string(md5($_POST['password'])) . "')");
// Check username and password match
if (mysql_num_rows($login) == 1) {
// Set username session variable
$_SESSION['username'] = $_POST['username'];
// Jump to secured page
header('Location: securedpage.php');
}
else {
// Jump to login page
header('Location: index.php');
}
?>
securedpage.php
<?php
// Inialize session
session_start();
// Check, if username session is NOT set then this page will jump to login page
if (!isset($_SESSION['username'])) {
header('Location: index.php');
}
?>
<html>
<head>
<title>Secured Page</title>
</head>
<body>
<p>This is secured page with session: <b><?php echo $_SESSION['username']; ?></b>
<br>You can put your restricted information here.</p>
<p><a href="logout.php">Logout</a></p>
</body>
</html>
'config.inc'輸出什麼東西? – Kermit
@FreshPrinceOfSO config.inc上沒有輸出 – ivandinglasan
請檢查我的新郵政編碼先生,謝謝 – ivandinglasan