-
Notifications
You must be signed in to change notification settings - Fork 0
/
reg.php
105 lines (105 loc) · 2.36 KB
/
reg.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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>用户注册</title>
</head>
<?php
echo"<center>";
if(!$_POST["name"])
{
?>
<script language="javascript">
function check(f)
{
if(f.name.value=="")
{
alert("请输入用户员名称");
f.admin.focus();
return false;
}
if(f.pass.value=="")
{
alert("请输入用户密码");
f.pass.focus();
return false;
}
if(f.re_pass.value !=f.pass.value)
{
alert("密码验证错误");
f.re_pass.focus();
f.re_pass.select();
return false;
}
if(f.mail.value=="")
{
alert("请输入注册用户员邮箱");
f.mail.focus();
return false;
}
}
</script>
<style type="text/css">
td{
font-size:21px;
}
</style>
<body>
<table border="1"cellspacing="0"cellpadding="1"bordercolordark="#fffff"bordercolorlight="#990033"width="300">
<form method="post" action="<?php $SERVER["PHP_SELF"]?>" onsubmit="return check(this)">
<tr>
<td colspan="2" bgcolor="#0066CC" align="center" >注册用户员信息</td>
</tr>
<tr>
<td>注册用户名称</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>用户密码</td>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<td>确认密码</td>
<td><input type="password"name="re_pass"></td>
</tr>
<tr>
<td>用户邮箱</td>
<td><input type="text"name="mail"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="注册"></td>
</tr>
</form>
</table>
<?php
}
else
{
$name=$_POST["name"];//取得文件的值
$pass=md5($_POST["pass"]); //md5在线加密
$mail=$_POST["mail"];
$time=date("Y年m月d日");
include"config.php";//加载配置文件
$sql="SELECT count(*) FROM $my_user WHERE name='$name'";
$re=mysql_query($sql,$my_conn)or die(mysql_error());
$count=mysql_fetch_row($re);//获取同名用户数量
if($count[0]>0)//因为只有一行所以count[0]就可以输出所有数
{
echo"已经存在用户名<p>";
echo"点击<a href=reg.php>这里</a>注册新用户 点击<a href=login.php>这里</a>登录";
}
else
{
$sql="INSERT INTO $my_user(name,password,email,reg_date)values('$name','$pass','$mail','$time')";
$re=mysql_query($sql,$my_conn)or die(mysql_error());
if($re)
{
echo "成功注册用户:".$name."<p>";
echo"点击<a href=login.php>这里</a>登录";
}
}
}
echo"</center>";
?>
</body>
</html>