注册界面
html>
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
用户注册邮箱 | |
密码 | |
确认 | |
性别 | 男 女 保密 |
级别 | 初级 中级 高级 |
语言 | java c php 无 |
简介 | |
提交 |
运行实例 »
点击 "运行实例" 按钮查看在线实例
regiess.css
table {
margin: 0 auto;
background-color: #BB996C;
box-shadow: 10px 10px 10px #BB996C;
}
caption {
font-size: 1.1em;
color: #00CC66;
background: #BB996C;
}
textarea {
resize: none;
}
#buttontd {
text-align: center;
}
button {
border-radius: 5px 5px 5px 5px;
box-shadow: 2px 2px 2px #00a2d4;
}
运行实例 »
点击 "运行实例" 按钮查看在线实例
regiess.js
/医院
* 在执行对应操作前执行上个对象非空判断。否则会出现死循环bug程序不停执行循环请求结果都是null
*/
$(document).ready(function () {
$('#email').blur(function () {
if ($('#email').val().length == 0) {
$('#email').next().remove();
$('#email').after('').next().text("邮箱不能为null").css("color","red");
return;
}
var url = 'userRegister/registerCheck.php?check=email';
$.post(
url,
'email=' + $('#email').val(),
function (data) {
switch (data.code) {
case 0:
$('#email').next().remove();
$('#email').after('').next().text(data.msg).css("color","green");
break;
case 1:
$('#email').next().remove();
$('#email').after('').next().text(data.msg).css("color","red");
break;
case 2:
$('#email').next().remove();
$('#email').after('').next().text(data.msg).css("color","red");
break;
}
}, 'json'
)
})
$('#password').blur(function () {
if ($('#email').val().length == 0) {
$('#email').next().remove();
$('#email').after('').next().text("邮箱不能为null");
return;
}
if ($('#password').val().length == 0) {
$('#password').next().remove();
$('#password').after('').next().text("密码不能为null");
return;
}
var url = 'userRegister/registerCheck.php?check=password';
$.post(
url,
'password=' + $('#password').val(),
function (data) {
switch (data.code) {
case 0:
$('#password').next().remove();
$('#password').after('').next().text(data.msg);
break;
case 1:
$('#password').next().remove();
$('#password').after('').next().text(data.msg);
break;
}
}, 'json'
)
})
$('#passwordSure').blur(function () {
if ($('#email').val().length == 0) {
$('#email').next().remove();
$('#email').after('').next().text("邮箱不能为null");
return;
}
if ($('#password').val().length == 0) {
$('#password').next().remove();
$('#password').after('').next().text("密码不能为null");
return;
}
if ($('#passwordSure').val().length == 0) {
$('#passwordSure').next().remove();
$('#passwordSure').after('').next().text("确认密码不能为null");
return;
}
var url = 'userRegister/registerCheck.php?check=passwordSure';
$.post(
url,
{
'password': $('#password').val(),
'passwordSure': $('#passwordSure').val()
},
function (data) {
switch (data.code) {
case 0:
$('#passwordSure').next().remove();
$('#passwordSure').after('').next().text(data.msg);
break;
case 1:
$('#passwordSure').next().remove();
$('#passwordSure').after('').next().text(data.msg);
break;
}
}, 'json'
)
})
$('#intro').blur(function () {
var url = 'userRegister/registerCheck.php?check=intro';
$.post(
url,
'intro=' + $('#intro').val(),
function (data) {
switch (data.code) {
case 0:
$('#intro').next().remove();
$('#intro').after('').next().text(data.msg);
break;
case 1:
$('#intro').next().remove();
$('#intro').after('').next().text(data.msg);
break;
case 2:
$('#intro').next().remove();
$('#intro').after('').next().text(data.msg);
break;
}
}, 'json'
)
})
//提交数据
$('#submit').click(function () {
var url = 'userRegister/registerCheck.php?check=submit';
$.post(url, $('#register').serialize(), function (data) {
// $('#submit').next().remove();
// $('#submit').after('').next().text(dataOut.msg +dataOut.data.password);
alert(data);
}, 'text')
})
})
运行实例 »
点击 "运行实例" 按钮查看在线实例
regiestCheck.php
/医院
* Created by PhpStorm.
* User: Administrator
* Date: 2018/4/17 0017
* Time: 上午 11:12
* 验证邮箱 密码 确认密码 等等 其他不用验证 有默认值 最后直接取出来就好了。
*/
header("content-type:text/html;charset=utf-8");
if (!empty($_GET['check'])) {
$check = $_GET['check'];
switch ($check) {
case 'email':
$email = $_POST['email'];
if (empty($_POST['email'])) {
exit(json_encode(['code' => 1, 'msg' => '邮箱不能为空']));
} else if (in_array($_POST['email'], array('admin@163.com', 'admin@qq.com'))) {
exit(json_encode(['code' => 2, 'msg' => '邮箱重复']));
} else {
exit(json_encode(['code' => 0, 'msg' => '可以注册']));
}
break;
case 'password':
$password = $_POST['password'];
if (empty($_POST['password'])) {
exit(json_encode(['code' => 1, 'msg' => '密码不能为空']));
} else {
exit(json_encode(['code' => 0, 'msg' => '密码通过']));
}
break;
case 'passwordSure':
$password = $_POST['password'];
$passwordSure = $_POST['passwordSure'];
if ($password == $passwordSure) {
exit(json_encode(['code' => 0, 'msg' => '密码通过']));
} else {
exit(json_encode(['code' => 0, 'msg' => '两次密码不一致']));
}
break;
case 'intro':
$intro = $_POST['intro'];
if (empty($intro)) {
exit(json_encode(['code' => 1, 'msg' => '简介不能为空']));
} else {
if (strlen($intro)
exit(json_encode(['code' => 2, 'msg' => '简介长度不能<10']));
} else {
exit(json_encode(['code' => 0, 'msg' => '简介验证通过']));
}
}
break;
case 'submit':
// echo $_POST['email'];
// echo "
";
// echo $_POST['password'];
// echo "
";
// echo $_POST['passwordSure'];
// echo "
";
// $sex = $_POST['sex'];
// echo $sex;
// echo "
";
// $level = $_POST['level'];
// echo $level;
// echo "
";
// $language = $_POST['language'];
// var_dump($language);
exit(json_encode(['code' => 0, 'msg' => '注册成功了', 'data' => array($_POST['email'], $_POST['password'], $_POST['passwordSure'], $_POST['sex'], $_POST['level'], $_POST['language'])]));
break;
}
}
运行实例 »
点击 "运行实例" 按钮查看在线实例