<?php
require("config.php");
require("conn.php");
$username=null;
$userpass=null;
$username=$_POST['username'];
$userpass=$_POST['userpass'];
$chknumber=$_POST['chknumber'];
if(intval($chknumber)!=intval($_COOKIE['code'])){
echo "{success:false,message:\"登录失败!你输入的验证码不正确!\"}";
}else{
$userpass=md5($userpass);
$result=mysql_query("select * from user where name='$username'",$db);
$myrow=mysql_fetch_array($result);
//sleep(20);
if($myrow["passwd"]==$userpass && $userpass!=null){
	setcookie("login","ok");
	session_start();
	$_SESSION['login']="ok";
	echo "{success:true,message:\"登录成功!\"}";
}else {
	echo "{success:false,message:\"登录失败!你输入的帐号或密码不正确!\"}";
}
}
//}
?>