привет, у меня проблемы с скриптом входа для моего сайта. Мне нужен скрипт для исправления пользователя 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 Injection!] (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). ** Узнайте о [подготовленных заявлениях] (http://en.wikipedia.org/wiki/Prepared_statement) ** и ** используйте [PDO] (http://us1.php.net/pdo). ** –