Exemplo n.º 1
0
 public function updatechangepasswordAction()
 {
     global $mySession;
     $db = new Db();
     $this->_helper->layout->setLayout('myaccount');
     $myform = new Form_Changepassword();
     $this->view->myform = $myform;
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         $myform = new Form_Changepassword();
         if ($myform->isValid($request->getPost())) {
             $dataForm = $myform->getValues();
             $qury = $db->runquery("Select * from " . USERS . "");
             //$password=$qury[0]['password'];
             if ($dataForm['currentpass'] == $qury[0]['password']) {
                 $pass = $dataForm['newpass'];
                 $cnfrm = $dataForm['cnfrmnewpass'];
                 if ($pass == $cnfrm) {
                     $myObj = new Myaccountdb();
                     // call to model
                     $data = $myObj->changepass($dataForm);
                     if ($data == 1) {
                         $mySession->errorMsg = "Password updated successfully";
                         $this->_redirect('myaccount/changepassword');
                     }
                 } else {
                     $mySession->errorMsg = "password is not same";
                     $this->render('changepassword');
                 }
             } else {
                 $mySession->errorMsg = "Your Current Password does not match";
                 $this->render('changepassword');
             }
         } else {
             $this->view->myform = $myform;
             $this->render('changepassword');
         }
     } else {
         $this->_redirect('myaccount/changepassword');
     }
 }