-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadduser.php
More file actions
81 lines (79 loc) · 2.28 KB
/
Copy pathadduser.php
File metadata and controls
81 lines (79 loc) · 2.28 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>添加会员页面</title>
<link rel="stylesheet" type="text/css" href="./css/adduser.css"/>
</head>
<body>
<div id="adduser_frame">
<form action="" method="post" name="form1" class="adduser">
<h3>添加会员</h3>
<p>
<label class="label_input">姓名:</label>
<input class="text_field" type="text" name="xm" />
</p>
<p>
<label class="label_input" style="margin-left: -200px;">性别:</label>
<input type="radio" name="xb" value="男"/>男
<input type="radio" name="xb" value="女"/>女
</p>
<p>
<label class="label_input">密码:</label>
<input class="text_field" type="password" name="mm" />
</p>
<input class="button" type="submit" name="tj" value="提交"/>
<input class="button" type="reset" name="reset" value="全部重写"/>
<input class="button" type="submit" name="fh" value="返回管理页面"/>
</form>
</body>
</html>
<?php
if(isset($_POST["tj"]))
{
$xm=$_POST["xm"];
$xb=$_POST["xb"];
$mm=$_POST["mm"];
$flag = 1;
$con=@mysql_connect('localhost','root',"root")or die("连接失败".mysql_error());
mysql_query("set names utf8");
mysql_query("set character set utf8");
mysql_query("set character_set_set_results= utf8");
$s=@mysql_select_db("BookLoanSystem") or die('选择数据库失败');
$selectSQ= "select * from User";
$result = @mysql_query($selectSQ);
if ($xm==null)
{
echo"<script>alert('用姓名名不能为空!'); </script>";
}
else
{
while($row=mysql_fetch_array($result))
{
$xm1=$row['user_name'];
if($xm==$xm1&&$xb==$row['user_sex'])
{
$flag=0;
echo"<script>alert('该用户名已存在!'); </script>";
break;
}
}
if(strlen($mm)<6){
echo"<script>alert('密码不能少于6位!'); </script>";
}
else if($flag==1){
$exec="insert into user values('null','$xm','$xb','$mm')";
$result=@mysql_query($exec);
if($result)
{
echo "<script>alert('添加成功'); </script>";
}
else echo "<script>alert('添加失败'); </script>";
}
}
}
$close=@mysql_close($con);
if(isset($_POST["fh"])){
header("location:../guanli.php");
}
?>