사용자 이름과 비밀번호에 대한 정확한 데이터를 입력 했더라도 로그인 페이지가 다음 웹 페이지로 리다이렉트하지 않습니다.데이터베이스가 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 페이지
<?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