<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网站后台管理中心</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />

<style>


body { font-family:Arial, 微软雅黑, 'Microsoft YaHei'; }

.box { 
display:flex;
flex-direction:column;
align-items:center;

}

.he { height:400px; width:320px; position: absolute; top: 30%; margin-top: -140px; left: 50%; margin-left: -150px;}
.table td { line-height:40px; padding:5px;}

.anniu { height:30px; padding-left:20px; padding-right:20px; line-height:30px; border:0px; cursor:pointer; background-color: #0099FF; color:white;  font-family:"Microsoft Yahei";}
.table input { height:30px;}

</style>

</head> 
<body> 
<FORM METHOD=POST ACTION="" autocomplete="off"> 
<div class="box">
   
   <div class="he">
   
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table">
		  <tr>
			<td>用户名</td>
			<td><INPUT TYPE="text" NAME="user" style="width:150px;" onkeyup="this.value=this.value.replace(/^ +| +$/g,'')"></td>
		  </tr>
		  <tr>
			<td>密 码</td>
			<td><INPUT TYPE="password" NAME="pwd" style="width:150px;" onkeyup="this.value=this.value.replace(/^ +| +$/g,'')" ></td>
		  </tr>
		  
		  <tr>
			<td>&nbsp;</td>
			<td><INPUT TYPE="submit" name="submit" value="登陆" class="anniu" ></td>
		  </tr>
		</table>


			

   </div>

</div>
</FORM>

</body> 
</html>
<?php 


require_once '../conn.php';
require_once '../function.php';

if($_POST['submit']){

		$user=$_POST['user'];
		$pwd=$_POST['pwd'];
	

		$row=query("select * from admin where user='$user'");

		$auser=$row['user'];
		$apwd=$row['pwd'];



		if ($user != $auser || $pwd != $apwd) 
		{ 
				 exit("<script>alert('用户名密码错误!');window.location.href='index.php';</script>");
			  
			   
		}else{

		setcookie("admin_user",$auser,(time()+3600*24));

		 exit("<script>alert('登陆成功!');window.location.href='main.php';</script>");

		}
}
?>
