-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
70 lines (70 loc) · 2 KB
/
signup.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
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<meta meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<head>
<title>注册</title>
</head>
<body>
<?php
if(isset($_POST['add']))
{
$dbhost = 'localhost:3306';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if(!$conn)
{
die('Could not connect:'.mysql_error());
}
if(!get_magic_quotes_gpc())
{
$user_name = addslashes($_POST['user_name']);
$password = addslashes($_POST['password']);
$email_address = addslashes($_POST['email_address']);
}
else
{
$user_name = $_POST['username'];
$password = $_POST['password'];
$email_address = $_POST['email_address'];
}
$sql = "INSERT INTO users".
"(user_name,password,email_address)".
"VALUES".
"('$user_name','$password','$email_address');";
mysql_select_db('XUANKE');
$retval = mysql_query($sql,$conn);
if(!$retval)
{
die("Could not enter data:".mysql_error());
}
echo "Entered data successfully!\n";
mysql_close($conn);
}
else
{
?>
<form role="form" method="post" action="<?php $_PHP_SELF ?>">
<div class="form-group">
<label for="user_name">用户名</label><input type="text" class="form-control" id="user_name" name="user_name"/>
</div>
<div class="form-group">
<label for="email_address">注册邮箱地址</label><input type="email" class="form-control" id="email_address" name="email_address"/>
</div>
<div class="form-group">
<label for="password">注册密码</label><input type="password" class="form-control" id="password" name="password"/>
</div>
<div class="checkbox">
<label><input type="checkbox" />已确认</label>
</div>
<button type="submit" class="btn btn-default" id="add" name="add">提交</button>
</form>
<?php
}
?>
<script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>