session_start();
define('GUY','true');
require 'conn.php';
if($_GET['action']=='login'){
if($_SESSION['code']!=$_POST['yzm']){
echo'<script type="text/javascript"> alert("验证码错误!");location.href="login.php"; </script>';
exit;
}
if(empty($_POST['admin'])){
echo'<script type="text/javascript"> alert("请输入用户账号再登录!");location.href="login.php"; </script>';
exit;
}
if(empty($_POST['password'])){
echo'<script type="text/javascript"> alert("请输入用户密码再登录!");location.href="login.php"; </script>';
exit;
}
$_html=array();
$_html['admin']=trim($_POST['admin']);
$_html['password']=md5(trim($_POST['password']));
$_result=@mysql_query("select * from admin where admin='{$_html[admin]}' and password='{$_html['password']}'")or die('登录错误');
if(!!$_rows=mysql_fetch_array($_result)){
setcookie('username',$_rows['admin']);
header('location:index.php');
}else{
echo '<script type="text/javascript">alert("登录账号信息错误!");location.href="login.php";</script>';
}
}