コード例 #1
0
 public function indexAction()
 {
     if ($this->_request->isPost()) {
         //sign in
         if ($this->_getParam('type') == 'signin') {
             $login = $_POST['login'];
             $mdp = $_POST['password'];
             $user = new Application_Model_User();
             $connection = $user->login($login, $mdp);
             if (!isset($connection['id_user'])) {
                 echo "vous n'exister pas";
             } else {
                 if ($connection['is_blocked'] == '0') {
                     $this->sess = new Zend_Session_Namespace('user');
                     $this->sess->data = $connection;
                     $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'index', 'message' => 'connecter'), null, true));
                 } else {
                     $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'acces'), null, true));
                 }
             }
             // sign up
         } elseif ($this->_getParam('type') == 'signup') {
             $login = $_POST['login'];
             $mdp = $_POST['password'];
             $firstname = $_POST['first_name'];
             $lastname = $_POST['last_name'];
             $mail = $_POST['email'];
             $phone = $_POST['phone'];
             $address = $_POST['address'];
             $cp = $_POST['code_postal'];
             $ville = $_POST['ville'];
             $user = new Application_Model_User();
             $verif = $user->loginExist($login);
             if ($verif > 0) {
                 $this->_redirect($this->view->url(array('controller' => 'user', 'action' => 'index', 'login' => false), null, true));
             }
             $stat = $user->inscription($login, $mdp, $firstname, $lastname, $mail, $phone, $address, $cp, $ville);
             if ($stat != -1) {
                 $val = 'enregistrer';
             } else {
                 $val = 'erreur';
             }
             $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'index', 'message' => $val), null, true));
         }
     }
 }