<?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>注册:天天链接网</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=trim($_POST['user']);
	$pwd=$_POST['pwd'];
    
	if(strlen($user)<3){
	 exit("<script>alert('用户名不能低于3位数!!');window.history.go(-1);</script>");
	}
	
	
	$time=date("Y-m-d H:i:s");
	
	$sql="select * from user where user='$user'";	
	$row=query($sql);
	    
	
	if($row){
	 exit("<script>alert('该手机号已经存在!! 找回请扫站长微信');window.history.go(-1);</script>");
	}
	
	 $arr=array(
		'user'=>$user,
		'pwd'=>$pwd,		
		'time'=>$time
		);
		
		$sql=gzsql($arr);		 
		mysql_query("insert into user $sql");
		
	 setcookie("user",$user,time()+3600*24*365,'/');
	 exit("<script>alert('注册成功!');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="text" class="input" autocomplete="off" id="pwd"></td>
				  </tr> 
				  
				  <tr>
					<td></td>
					<td><input name="submit" type="submit" value="注册" class="anniu"> </td>
				  </tr>
				</table>
		
		</form>		
		</div>
	
   </div>



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

</div>

</body> 
</html>