<?


if(isset($_POST['nick']) && isset($_POST['password']))
{
include_once 'inc/head.php';
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `nick` = '".my_esc($_POST['nick'])."' AND `password` = '".md5(my_esc($_POST['password']))."' LIMIT 1"),0)==0)err_game("Неверный ник или пароль");
else
{
$_SESSION['id_user']=mysql_result(mysql_query("SELECT `id` FROM `kolhoz_user` WHERE `nick` = '".my_esc($_POST['nick'])."' AND `password` = '".md5($_POST['password'])."' LIMIT 1"),0);
$_SESSION['pass']=md5(my_esc($_POST['password']));
                $adm = base64_encode($_SESSION['id_user']);
                $passwd = base64_encode(md5(my_esc($_POST['password'])));
                setcookie("log_id", $adm, time() + 3600 * 24 * 7);
                setcookie("pass", $passwd, time() + 3600 * 24 * 7);
header("Location: http://$_SERVER[HTTP_HOST]/myfarm");
exit;
}
}
?>
<div class="event">
<div><h1>Вход</h1></div>
</div>
<div class="content">
<div class="block">
<form method="post"><ul>
<li>
<label>Ник:<br>
<input type="text" value="" name="nick">
</label>
</li>
<li class="pt">
<label>Пароль:<br>
<input type="password" value="" name="password">
</label>
</li>
<li class="pt">
<input type="submit" value="Войти">
</li>
</ul>
</form>
<div class="pt">
<ul>
<li><img width="16" height="16" src="images/icons/rename.png" alt="*">
<a href="/pass">Восстановление пароля</a></li>
</ul>
</div>
</div>
<div class="block event">
<img width="16" height="16" src="images/icons/back.png" alt="o"> <a href="/">В начало</a>
</div>
</div>
<?
include_once 'inc/foot.php';
exit;
?>