Exemple #1
0
 public function savepartpass()
 {
     try {
         if (Check::digits($_POST['study_id'], $empty = false)) {
             $study_id = $_POST['study_id'];
         } else {
             throw new Exception("bad study id!");
         }
         if (Check::digits($_POST['participant_id'], $empty = false)) {
             $part_id = $_POST['participant_id'];
         } else {
             throw new Exception("need a participant id!");
         }
         if ($_POST['password'] != $_POST['confirmpassword']) {
             throw new Exception("passwords don't match!");
         } else {
             $password = $_POST['password'];
         }
         if (!Check::validpassword($password)) {
             throw new Exception(Check::err());
         }
         $p = new Participant();
         if ($p->upd($part_id, array('password' => md5("{$password}"))) == false) {
             throw new Exception($p->err());
         }
         View::assign('study_id', $study_id);
         return 'participants.tpl';
     } catch (Exception $e) {
         $this->err($e);
         View::assign('error', $this->error);
         return 'error.tpl';
     }
 }