File size: 1.43Kb
<?php
require_once "../system/connect.php";
require_once "../system/config.php";
require_once "../system/functions.php";
require_once "../system/dannuser.php";
require_once "../system/start.php";
if($_SESSION['slogin']!='' && $_SESSION['spass']!='') {
Header("Location: index.php?isset=reg2");
} else {
echo '<form action="avtori.php" method="post">
Логин:
<br><input type="text" name="l"><br>
Пароль:
<br><input type="password" name="p"><br>
<input type="submit" name="sub" value="Вход"></form>';
echo '<a href="/index.php"> На главную</a><br></div>'; }
if(isset($_POST['sub'])) {
$l=check($_POST['l']);
$p=check($_POST['p']);
if(empty($l) || empty($p)) { Header("Location: index.php?isset=form"); } else {
$q=mysql_query("SELECT * FROM `users` WHERE `login`='".$l."';");
$ar=mysql_fetch_array($q);
if($l==$ar[login] && md5($p)==$ar[password])
{ $log_encode=hard_encode($l, $key);
SetCookie("clog", $log_encode, time()+3600*24*365);
$_SESSION['slogin']=$l;
$_SESSION['spass']=$p;
Header("Location: http://legos.org.ru/index.php"); exit;
} else { header ("Location: ../index.php?isset=no_reg"); }}}
if($act=="exit"){
unset($_SESSION['slogin']);
unset($_SESSION['pass']);
setcookie('clog', '');
session_unset();
setcookie(session_name(), '');
session_destroy();
header ("Location: index.php?isset=exit"); exit;
}
require_once "../foot.php";
?>