-
Notifications
You must be signed in to change notification settings - Fork 1
/
register.php
61 lines (53 loc) · 2.19 KB
/
register.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
<?php include('header.php'); ?>
<?php
$GLOBALS['register']['form'] = '';
if (empty($_POST['username']) || empty($_POST['password'])) {
$GLOBALS['register']['form'] = '请填写完整';
} else {
$u = User::getByUsername($_POST['username']);
if ($u->password) {
$GLOBALS['register']['form'] = '用户名已存在';
} else {
$u->username = $_POST['username'];
$u->password = $_POST['password'];
$u->save();
// $GLOBALS['register']['form'] = '注册成功';
setcookie('username', $_POST['username'], time() + 60 * 60 * 24 * 30 * 6);//设置时效6个月,6个月后这个cookie失效
setcookie('password', sha1($_POST['password']), time() + 60 * 60 * 24 * 30 * 6);
redirect('index.php');
}
}
?>
<!-- container -->
<div class="container">
<!-- page hd -->
<header class="page_hd"><a href="index.php"><img src="img/logo.svg" alt="logo"></a></header>
<!-- page bd -->
<div class="page_bd">
<form action="" method="post">
<div class="weui-cells__title"><?php if (isset($_POST['submit'])) {
echo $GLOBALS['register']['form'];
} ?></div>
<div class="weui-cells">
<div class="weui-cell">
<div class="weui-cell__bd">
<input class="weui-input" type="text" placeholder="Email" name="username"
value="<?php if (isset($_POST['submit'])) {
echo $_POST['username'];
} ?>">
</div>
</div>
<div class="weui-cell">
<div class="weui-cell__bd">
<input class="weui-input" type="password" placeholder="Password" name="password">
</div>
</div>
</div>
<div class="weui-btn-area">
<input type="submit" name="submit" value="Register" class="weui-btn weui-btn_primary">
</div>
<div class="weui-loadmore"><span class="weui-loadmore__tips"><a href="login.php">Login</a></span></div>
</form>
</div>
</div>
<?php include('footer.php') ?>