View file include/avto.php

File size: 704B
<?
include ("bd.php");

if (isset($_POST['auth_name'])) 
{
$name=mysql_real_escape_string($_POST['auth_name']);
$pass=mysql_real_escape_string($_POST['auth_pass']);
$query = "SELECT * FROM `shurik_users` WHERE login='$name' AND pass='$pass'";
$res = mysql_query($query) or trigger_error(mysql_error().$query);

if ($row = mysql_fetch_assoc($res)) 
{
session_start();
$_SESSION['user_id'] = $row['id'];
header("Location: ../index.php");
}

else echo 'Ошибка!<br>Не правильный логин или пароль<br><a href=../index.php>Вернуться</a>';
exit;
}


if (isset($_REQUEST[session_name()])) {@session_start();}
if (isset($_SESSION['user_id'])) return;
else {
//если не авторизирован
}
?>