<!DOCTYPE html>
<html>
<head>
<title>注册界面</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="public/css/style1.css" rel='stylesheet' type='text/css' />
<script type="text/javascript" src="public/js/jquery.js"></script>
<script type="text/javascript" src="public/static/layer/layer.js"></script>
</head>
<body>
	<!--注册部分-->
	<div class="main">
		<div class="login" >
			<div class="inset">
				<!--start-main-->
				<form id="register" method="post">
			         <div>
			         	<h2>微博注册</h2>
						<span><label>用户名</label></span>
						<span><input type="text" class="textbox" name="username" ></span>
					 </div>
					 <div> 
						<span><label>密码</label></span>
					    <span><input type="password" class="password" name="password"></span>
					 </div>
					  <div> 
						<span><label>再次输入密码</label></span>
					    <span><input type="password" class="password" name="password1"></span>
					 </div>
					<div class="sign">
                        <input type="submit" value="注册" class="submit"  />
					</div>
				</form>
				</div>
				<span style="text-align: right; margin-top: 30px;">已有账号，点击
							<a href="login.php">登录</a>
				</span>
			</div>
		<!--//end-main-->
		</div>

<div class="copy-right">
	<p>&copy; 2018 MyWeiBo Login Form. All Rights Reserved</p>

</div>
<div style="text-align:center;">
<p>有关网页：<a href="http://www.baidu.com/" target="_blank">百度</a></p>
</div>
<script>

    //设置此处的原因是每次进入界面展示一个随机的验证码，不设置则为空
    window.onload = function (){

        createCode();
    }

	//登陆功能部分
    $('#register').click(function(){
        var username  = $("input[name='username']").val();
        var password  = $("input[name='password']").val();
        var password1  = $("input[name='password1']").val();
        //js验证用户名和密码是否填写
        if(username == ''){
            layer.msg('请填写用户名');
            return false;
        }
        if(password == ''){
            layer.msg('请填写密码');
            return false;
        }
        if(password !== password1)
        {
        	layer.msg('请保证2次密码一致');
        	return false;
        }
        //js验证
        //AJAX异步提交账号 jQuery ajax - post() 方法 第一个参数是地址 第二个是东西 第三个是回掉函数
       $.post("ajaxRegister.php", {username: username,password:password}, function(data) {
            if (data == -1) {
                layer.msg('用户名已存在');
                return false;
            }
            if (data == 1){
                layer.msg('注册成功',{time:1000},function(){
                    window.location.href = "login.php";
                });
            }else{
                layer.msg('注册失败');
                return false;
            }
        });
        return false;
    });
</script>
</body>
</html>
<?php
	/*2018/2/18*/

  

?>