<?php 
require_once 'conn.php';
require_once 'function.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"/>
<title>登录:22链接网</title>
<meta name="keywords" content="<?=$site['keywords']?>"/>
<meta name="description" content="<?=$site['description']?>"/>

<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="page.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="open.css">
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>

<script>

function kan(id){

$.get("kan.php", { tid: id, time: "2pm" },
  function(data){
   
     $("#tong").html(data);
     layer.open({
	  type: 1,
	  title: false,
	  closeBtn: 1,
	  area: ['90%', '50%'],
	  skin: '', //没有背景色
	  shadeClose: true,
	  content: $('#tong')
	});
   
  });

}




function check(){

 var user=$("#user").val(); 
 if(user==''){
 alert('请输入用户名');
 return false;
 }
 
 var pwd=$("#pwd").val();
 if(pwd==''){
 alert('请输入密码');
 return false;
 }
 


}



</script>


</head>
<body>
<?php 

if($_POST['submit']){

	$user=$_POST['user'];
	$pwd=$_POST['pwd'];
	
	
	$row=query("select * from user where user='$user'");

	$auser=$row['user'];
	$apwd=$row['pwd'];
	
	if(empty($user)){
	   exit("<script>alert('请输入用户名!');window.history.go(-1);</script>");
	}
	
	if(empty($pwd)){
	   exit("<script>alert('请输入密码!');window.history.go(-1);</script>");
	}
	
	
	
	
	if ($_POST['user']!=$auser || $_POST['pwd']!=$apwd) 
	{ 
			 exit("<script>alert('用户名密码错误!');window.history.go(-1);</script>");
		  
		   
	}else{
	
	 setcookie("user",$user,time()+3600*24*365,'/');	
	
	 exit("<script>window.location.href='index.php';</script>");
	
	}
}
?>


<?php 
require_once 'head.php';
?>
<div class="container">

   <div class="box">
		 <div class="row">
		<form action="" method="post" onSubmit="return check();">
				<table  class="table table-bordered">
				  <tr>
					<td>用户名</td>
					<td><input name="user" type="text" class="input" autocomplete="off" id="user">   </td>
				  </tr>
				  <tr>
					<td>密码</td>
					<td><input name="pwd" type="password" class="input" autocomplete="off" id="pwd"></td>
				  </tr> 
				  
				  <tr>
					<td></td>
					<td><input name="submit" type="submit" value="登录" class="anniu"> <span style="margin-left:40px;"><a href="lx.php">?忘记密码</a></span></td>
				  </tr>
				</table>
		
		</form>		
		</div>
	

  </div>


<?php require_once 'foot.php';?>

</div>






</body> 
</html>