-
Notifications
You must be signed in to change notification settings - Fork 27
/
userreg.php
198 lines (194 loc) · 6.69 KB
/
userreg.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
include_once 'conn.php';
$ndate =date("Y-m-d");
?>
<link rel="stylesheet" href="css/style.css" />
<script src="js/jquery-2.1.3.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/sweetalert.min.js" type="text/javascript" charset="utf-8"></script>
<?php
if ($addnew=="1" ){
if(isset($_POST['zhanghao'])){
$search = "select zhanghao from yonghuzhuce where zhanghao='$zhanghao'";
$zhanghao=$_POST["zhanghao"];
$mima=$_POST["mima"];
//MD5加盐加密
$salt="skjddq237:&*^$df234GJSN";
$mima=$mima+$salt;
$mima=md5($mima);
$res=mysql_query($search);
if(mysql_num_rows($res)>0){
echo
"<script>
$(function(){
swal('失败','用户名已存在','error')});
</script>";
}else {
$query="insert into yonghuzhuce(zhanghao,mima) values ('$zhanghao','$mima')";
if(mysql_query($query)){
echo
"<script>
$(function(){
swal('成功','注册成功','success').then(() => {
location.href='index.php';
})});
</script>";
}else{
echo '失败,请重新尝试!',mysql_error();
}
die;
}
}
}
?>
<html>
<head>
<title>酒店管理信息系统</title>
</head>
<!--注册-->
<div class="reg txt_none" id="reg_show">
<div class="reg_box">
<span class="close"><img src="img/close.png"/></span>
<h2>用户注册</h2>
<form name="form1" method="post" action="">
<ul>
<li>
<span class="user"><img src="img/user.png"/></span>
<input type="text" name="zhanghao" id="zhanghao" value='' placeholder="用户名" autocomplete="off"/>
<input type='text' style='display:none'> <!-- 针对firefox -->
</li>
<li>
<span class="password"><img src="img/password.png"/></span>
<input type="password" name="mima" class="pass" id="password" value='' placeholder="密码" autocomplete="new-password" readonly onFocus="this.removeAttribute('readonly');" onBlur="this.setAttribute('readonly',true);" />
<input type='text' style='display:none'> <!-- 针对firefox -->
</li>
<li style="margin-bottom:10px;">
<span class="password"><img src="img/password.png"/></span>
<input type="password" name="remima" class="pass" id="repassword" value='' placeholder="确认密码" autocomplete="new-password" readonly onFocus="this.removeAttribute('readonly');" onBlur="this.setAttribute('readonly',true);" />
<input type='text' style='display:none'> <!-- 针对firefox -->
</li>
<!--提示语-->
<p class="warning_tips1" id="warning_tips1"></p>
<p class="warning_tips2" id="warning_tips2"></p>
</ul>
<div class="bottom_box">
<input type="submit" name="Submit" value="注册" onclick="return check();"/>
<input type="hidden" name="addnew" value="1" />
</div>
<div class="login_link" id="login_link">
<p>已有账号?去<span>登录</span></p>
</div>
</form>
</div>
</div>
<!--注册end-->
<!--登录-->
<div class="reg txt_none" id="login_show">
<div class="reg_box">
<span class="close"><img src="img/close.png"/></span>
<h2>用户登录</h2>
<form name="userlog" method="post" action="userlog_post.php" id="userlog">
<ul class="login_box_ul">
<li>
账号:<input name="username" type="text" id="username" placeholder="请输入用户名" autocomplete="off"/>
<input type='text' style='display:none'> <!-- 针对firefox -->
</li>
<li>
密码:<input name="pwd1" type="password" id="pwd1" placeholder="请输入密码" readonly onFocus="this.removeAttribute('readonly');" onBlur="this.setAttribute('readonly',true);"/>
<input type='text' style='display:none'> <!-- 针对firefox -->
</li>
</ul>
<div class="bottom_box">
<input type="submit" name="Submit" value="登陆" />
<input type="reset" name="Submit2" value="重置" />
</div>
<div class="login_link" id="userreg_link">
<p>没有账号?去<span>注册</span></p>
</div>
</form>
</div>
</div>
<!--登录end-->
<script>
//用户名校验
var regExp = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{3,12}$/;//英文+数字,长度3-12位
$("#zhanghao").keyup(function(){
var $value=$(this).val();
if(!regExp.test($value)){
$('#warning_tips1').html("请输入3-12位的数字+英文组合的账号");
return false;
}else{
$('#warning_tips1').html("");
}
});
//密码校验
var passreg=new RegExp("^[0-9]{6,12}$");//密码长度为6-12位的数字
$("#password").keyup(function(){
var $value=$(this).val();
if(!passreg.test($value)){
$('#warning_tips2').html("请输入6-12位的纯数字密码");
return false;
}else{
$('#warning_tips2').html("");
}
});
//控制校验
function check(){
if(document.getElementById("zhanghao").value==""){
swal({
title: "失败!",
text: "请输入账号!",
icon: "error",
showConfirmButton: true
})
document.getElementById("zhanghao").focus();
return false;
}
if(document.getElementById("password").value==""){
swal({
title: "失败!",
text: "请输入密码!",
icon: "error",
showConfirmButton: true
})
document.getElementById("password").focus();
return false;
}
if(document.getElementById("repassword").value==""){
swal({
title: "失败!",
text: "请输入确认密码!",
icon: "error",
showConfirmButton: true
})
document.getElementById("repassword").focus();
return false;
}
if(document.getElementById("repassword").value != document.getElementById("password").value){
swal({
title: "失败!",
text: "两次密码不一致!",
icon: "error",
showConfirmButton: true
})
return false;
document.getElementById("password").value=="";
document.getElementById("repassword").value=="";
document.getElementById("password").focus();
}
if($('#warning_tips1').html() != "" || $('#warning_tips2').html() != ""){
swal({
title: "失败!",
text: "请输入正确的格式!",
icon: "error",
showConfirmButton: true
})
return false;
document.getElementById("zhaohao").value=="";
document.getElementById("password").value=="";
document.getElementById("repassword").value=="";
document.getElementById("zhaohao").focus();
}
}
</script>
</body>
</html>