2015-07-28 15:15:57 +08:00
|
|
|
<?php
|
|
|
|
|
namespace User\Controller;
|
|
|
|
|
use Think\Controller;
|
|
|
|
|
|
|
|
|
|
/**
|
2016-01-26 14:09:59 +08:00
|
|
|
* @author Zhou Yuyang <1009465756@qq.com> 11:28 2016/1/26
|
2016-01-24 11:54:16 +08:00
|
|
|
* @copyright 2105-2018 SRCMS
|
2015-07-28 15:15:57 +08:00
|
|
|
* @homepage http://www.src.pw
|
2016-01-26 14:09:59 +08:00
|
|
|
* @version 1.6
|
2015-07-28 15:15:57 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 注册页面
|
|
|
|
|
*/
|
|
|
|
|
class RegController extends Controller{
|
|
|
|
|
/**
|
|
|
|
|
* 用户列表
|
|
|
|
|
* @return [type] [description]
|
|
|
|
|
*/
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
2016-01-25 10:53:12 +08:00
|
|
|
$tmodel= M('setting');
|
|
|
|
|
$title = $tmodel->where('id=1')->select();
|
|
|
|
|
$this->assign('title', $title);
|
2015-07-28 15:15:57 +08:00
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加用户
|
|
|
|
|
*/
|
|
|
|
|
public function add()
|
|
|
|
|
{
|
|
|
|
|
//默认显示添加表单
|
|
|
|
|
if (!IS_POST) {
|
|
|
|
|
$this->display();
|
|
|
|
|
}
|
|
|
|
|
if (IS_POST) {
|
|
|
|
|
//如果用户提交数据
|
|
|
|
|
$model = D("Member");
|
2016-01-26 14:09:59 +08:00
|
|
|
if (!$model->field('username,email,password,repassword')->create()) {
|
2015-07-28 15:15:57 +08:00
|
|
|
// 如果创建失败 表示验证没有通过 输出错误提示信息
|
|
|
|
|
$this->error($model->getError());
|
|
|
|
|
exit();
|
|
|
|
|
} else {
|
|
|
|
|
if ($model->add()) {
|
2016-01-26 14:09:59 +08:00
|
|
|
$this->success("注册成功", U('index/index'));
|
2015-07-28 15:15:57 +08:00
|
|
|
} else {
|
2016-01-26 14:09:59 +08:00
|
|
|
$this->error("注册失败");
|
2015-07-28 15:15:57 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|