안녕 내 웹 사이트에 대한 로그인 스크립트에 문제가 생겼습니다 로그인 정보가 올바른 경우 index.html로 사용자를 다시 작성하는 스크립트가 필요합니다. 당신이 전혀 크게 감사하겠습니다 나를 도울 수 있다면 .. 어떤 도움을 크게 감상 할 수PHP 어떻게 성공적으로 로그인 index.html 사용자를 리디렉션
<?php
include('config.php');
?>
$ousername = '';
//We check if the form has been sent
if(isset($_POST['username'], $_POST['password']))
{
//We remove slashes depending on the configuration
if(get_magic_quotes_gpc())
{
$ousername = stripslashes($_POST['username']);
$username = mysql_real_escape_string(stripslashes($_POST['username']));
$password = stripslashes($_POST['password']);
}
else
{
$username = mysql_real_escape_string($_POST['username']);
$password = $_POST['password'];
}
//We get the password of the user
$req = mysql_query('select password,id from users where username="'.$username.'"');
$dn = mysql_fetch_array($req);
//We compare the submited password and the real one, and we check if the user exists
if($dn['password']==$password and mysql_num_rows($req)>0)
{
//If the password is good, we dont show the form
$form = false;
//We save the user name in the session username and the user Id in the session userid
$_SESSION['username'] = $_POST['username'];
$_SESSION['userid'] = $dn['id'];
?>
<?php
}
else
{
//Otherwise, we say the password is incorrect.
$form = true;
$message = 'The username or password is incorrect.';
}
}
else
{
$form = true;
}
if($form)
{
//We display a message if necessary
if(isset($message))
{
echo '<div class="message">'.$message.'</div>';
}
//We display the form
?>
==> 세부 사항을 확인하기 위해 여기
내 스크립트입니다 ... 감사합니다 ... 감사합니다 당신.
사용해보기 : header ('위치 : http://www.example.com/'); –
더 이상 mysql_ * 확장을 사용하면 안됩니다. mysqli 나'PDO'를 살펴보십시오. – muttley91
** [위험! 당신은 SQL 주입을 방지해야합니다!] (** http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) ** [mysql_ * 'functions] (http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). ** 더 이상 유지 관리되지 않으며 공식적으로 사용되지 않습니다 (https :// /wiki.php.net/rfc/mysql_deprecation). ** 대신 [prepared statements] (http://en.wikipedia.org/wiki/Prepared_statement) **에 대해 알아보고 ** [PDO] (http://us1.php.net/pdo)를 사용하십시오. ** –