function register()
 {
     //        $user = D('User');
     $user = new \Model\UserModel();
     if (!empty($_POST)) {
         if (!$user->create()) {
             //验证失败,输出错误信息
             //                dump($user->getError());
             //                exit;
             $this->assign('error', $user->getError());
         } else {
             //把爱好由数组转变为字符串'1,2,3'的形式
             //使用ARf方式处理爱好的字段信息
             //create()方法收集的数据也是把数据变为模型对象的属性
             $user->user_hobby = implode(',', $_POST['user_hobby']);
             $rst = $user->add();
             if ($rst) {
                 $this->success('注册成功,正在跳转!', U('Index/index'), 3);
             } else {
                 echo 'error';
             }
         }
     } else {
         $this->display();
     }
 }
 function register(){
     $user = new \Model\UserModel();
     //判断表单是否提交
     if(!empty($_POST)){
         //只有全部验证通过$z才会为真
         if(!$user -> create()){
             //验证失败,输出错误信息
             //getError()方法返回验证失败的信息
             show_bug($user->getError());
         } else {
             //把爱好由数组变为字符串"1,3,4"
             //使用AR方式处理爱好的字段信息
             //create()方法收集的数据也是把数据变为模型对象的属性
             $user -> user_hobby = implode(',',$_POST['user_hobby']);
             $rst = $user -> add();
             if($rst){
                 $this -> success('注册成功',U('Index/index'));
             } else {
                 $this -> error('注册失败',U('Index/index'));
             }
         }
     } else {
         $this -> display();
     }
 }
 public function register()
 {
     //完成注册,注册完成发送一封激活邮件
     if (IS_POST) {
         $model = new \Model\UserModel();
         if ($data = $model->create()) {
             $validate = uniqid();
             $data['validate'] = $validate;
             if ($model->add($data)) {
                 //注册成功,发送邮件激活
                 $email = I('post.email');
                 $title = '注册用户,完成激活';
                 $url = "http://web.com/index.php/Home/User/active/key/" . $validate . "/email/" . $email;
                 $content = "亲,您已注册成功,赶紧激活使用吧!请<a href='{$url}'>单击激活</a>";
                 if (sendEmail($email, $content, $title)) {
                     $this->success('邮件发送成功,请尽快激活', U('login'), 1);
                     exit;
                 }
                 $this->error('发送邮件失败,请重新注册');
             }
             $this->error('注册失败');
         }
         $this->error($model->getError());
     }
     $this->display();
 }
 function register()
 {
     //$user=new \Model\UserModel();
     show_bug($_POST);
     $user = new \Model\UserModel();
     if (!empty($_POST)) {
         //print_r($_POST);
         $data = $user->create();
         //集成表单验证
         if (!$data) {
             show_bug($user->getError());
         } else {
             //添加数据
             $user->user_hobby = implode(',', $_POST['user_hobby']);
             $charu = $user->add();
             if ($charu) {
                 $this->success('注册成功', U('Index/index'));
             } else {
                 $this->error('注册失败', U('Index/index'));
             }
         }
     } else {
         $this->display();
     }
 }
Exemple #5
0
 public function register()
 {
     //展示表单,收集数据
     $user = new \Model\UserModel();
     if (!empty($_POST)) {
         $arr = $user->create();
         if ($arr) {
             $z = $user->add($arr);
             if ($z) {
                 $this->redirect('User/login');
             }
         }
         $this->assign('errorinfo', $user->getError());
         //获取验证错误信息
     }
     $this->display();
 }
 public function register()
 {
     $obj = new \Model\UserModel();
     if (!empty($_POST)) {
         $rand = rand(0, 9999);
         $url = substr(md5(time() - $rand), 12, 8);
         $_POST['url'] = $url;
         $_POST['time'] = time();
         $_POST['lovetime'] = $_POST['ltime'] ? strtotime($_POST['ltime']) : null;
         while (empty($_POST['content'])) {
             $content = M('poem');
             $poem = $content->query('select poem from poem where id=(select FLOOR(1 + (RAND() * (SELECT MAX(id) FROM `poem`)))) limit 1');
             $_POST['content'] = $poem['0']['poem'];
         }
         $z = $obj->create();
         if ($z) {
             $result = $obj->add();
             if ($result) {
                 echo '<script>alert("页面生成成功")</script>';
                 echo '<script>alert("记得记下网址链接哦,快快发给朋友们Show一下吧!")</script>';
                 echo '<script language="javascript" type="text/javascript">window.location.href="' . U('Home/Index/Index/id/' . $url) . '";</script>';
             } else {
                 echo '<script>alert("生成失败,请重新提交或联系")</script>';
                 echo '<script language="javascript" type="text/javascript">window.location.href="' . U('Home/Index/register') . '";</script>';
             }
         } else {
             $err = $obj->getError();
             echo '<script>alert("';
             foreach ($err as $key) {
                 echo $key . '\\n';
             }
             echo '")</script>';
             echo '<script language="javascript" type="text/javascript">history.go(-1);</script>';
             exit;
         }
     }
     if ($this->isMobile()) {
         $this->display('m_register');
     } else {
         $this->display();
     }
 }
 /**
  * [signup description] 前台用户注册
  * @Author   alanfang2012@163.com
  * @DateTime 2015-09-01T22:27:15+0800
  */
 public function signup()
 {
     if (!empty($_POST)) {
         $user_mod = new \Model\UserModel();
         $res = $user_mod->create();
         if ($res) {
             $p = $user_mod->makePwd($res['user_name'], $res['user_pswd']);
             $res['user_pswd'] = $p['user_pswd'];
             $res['salt'] = $p['salt'];
             $z = $user_mod->add($res);
             session('user_id', $z);
             session('user_name', $res['user_name']);
             if ($z) {
                 $this->redirect('user/info');
             }
         }
         $this->assign('errorInfo', $user_mod->getError());
     }
     $this->display();
 }
 function insert()
 {
     $user = new \Model\UserModel();
     if (!empty($_POST)) {
         //收集post表单数据	creat()会进行表单验证
         if (!$user->create()) {
             //验证失败,输出错误信息
             show_bug($user->getError());
             //返回添加页面
             $this->error('添加失败', 'javascript:history.back(-1)');
         } else {
             $rst = $user->add();
             if ($rst) {
                 $this->success('添加成功', U('User/manage'));
             } else {
                 $this->error('添加失败', U('User/manage'));
             }
         }
     } else {
         $this->display();
     }
 }