// $qwe = new mysqli('localhost','root','root','qwer');
// $pasd = md5(645524);
// $wer = "insert into wer (name,pasd) values ('mark','$pasd')";
// $res = $qwe->query($wer);
if($_POST){
// 接受变量
$name = trim($_POST['name']);
$pasd = md5($_POST['pasd']);
// 数据库
$qwe =new mysqli('localhost','root','root','qwer');
// 判断是否连接
if($qwe->connect_error){
echo $qwe->connect_error;
exit();//代码到此为止
}
$sqe = "select * from wer where name='$name' and pasd = '$pasd'";
$res =$qwe->query($sqe);
$info = $res->fetch_assoc();
if($res->num_rows == 0){
echo '<script>alert("用户名密码错误")</script>';
}else{
setcookie('admin',$info['id']);
header("location:index.php");
}
}