-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.php
70 lines (52 loc) · 1.5 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
62
63
64
65
66
67
68
69
70
<?php
/**
* 提供用户注册的程序
*
*
*
* */
require_once("dev/devapp.config.php");
require_once(ROOT_DIR . "/user/devapi.user.php");
if (s_bad_post('username', $username)) {
//没有填写账户
$wrong['username'] = '请填写您的手机或者邮箱做为登录账号';
}
if (s_bad_post('password', $password)) {
//没有填写密码
$wrong['username'] = '请填写你的登录密码';
}
if (s_bad_post('nickname', $nickname)) {
//没有填写昵称
$wrong['username'] = '请填写你的用户昵称';
}
if (user_by_username($username)) {
$wrong['username'] = '您使用的账号已被注册';
}
if (user_by_nickname($nickname)) {
$wrong['nickname'] = '您使用的昵称已被注册';
}
if (isset($wrong)) {
return s_action_page(array(
'error' => 10000,
'username' => $username,
'password' => $password,
'nickname' => $nickname,
'wrong' => $wrong,
), 'reg.tpl');
}
//查看token对应的用户是否已经被占用
$token = user_token_from_cookie();
if (!user_create_by_reg($username, $password, $nickname, $token) ) {
$wrong['message'] = '注册失败,请重新注册';
return s_action_page(array(
'error' => 10000,
'username' => $username,
'password' => $password,
'nickname' => $nickname,
'wrong' => $wrong,
), 'reg.tpl');
}
//模拟用户登录
user_login($username, $password);
//页面跳转到用户首页
s_action_redirect('main.php');