Просмотр файла aut.php

Размер файла: 1.17Kb
<?php
include_once 'inc/db.php';
session_start();
if ($user)header("Location: /index.php");
if (!$_POST['pass'] && !$_POST['name'])
{
include 'inc/1.php';
$_SESSION['captcha']=rand(11111, 99999);
echo "<div class='p0'><form action='#' method='POST'>Логин: <input type='text' name='name'><br>Пароль: <input type='password' name='pass'><br>$_SESSION[captcha]: <input type='text' name='captcha'><br><input type='submit' value='Вход'></form></p>";
}
else
{
if (($_SESSION['captcha']!=$_POST['captcha']) || (!$_POST['captcha']))die("Проверочное число введено неверно ($_SESSION[captcha])!");
$name=mysql_escape_string($_POST['name']);
$pass=md5($_POST['pass']);
$ma=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `name` = '$name'"));
$pass1=$ma['pass'];
if ($pass1==$pass){
$user=$ma;
if (!setCookie("name", $name, time()+9999999))die("Ошибка COOKIE! [x]<br>");
setCookie("pass", $pass, time()+9999999);
include 'inc/1.php';
mysql_query("UPDATE `user` SET `reply_on` = '0' WHERE `id` = '$ma[id]'");
header("Location: /hi.php");
}
else
{
include 'inc/1.php';
echo "Ошибка!";
}
}
include 'inc/foot.php';
?>