Exemplo n.º 1
0
 /**
  * Creates a new user with the given infomation
  * @param type $ID user's registration number
  * @param type $password user's password
  * @param type $email user's email address
  * @param type $first_name user's first name
  * @param type $last_name user's last name
  * @param type $phone user's phone number
  * @return boolean returns true if user's data was successfully registered, false otherwise
  */
 public function registerUser($ID, $password, $retypedPassword, $email, $first_name, $last_name, $phone)
 {
     // Validate details
     $ok = strcmp($password, $retypedPassword) === 0;
     if ($ok) {
         $ok = $this->validateInfo($ID, $email, $first_name, $last_name, $phone, $password);
     } else {
         throw new Exception("Passwords do not match");
     }
     // Add to database
     if ($ok) {
         $ok = $this->addNewUser($ID, $password, $email, $first_name, $last_name, $phone);
     }
     // Mail login id and password to user
     if ($ok) {
         try {
             sendMail($email, "Login Details", UserUtility::getVerificationMessage($ID, $password));
         } catch (Exception $exc) {
             //Mailing failed
             UserUtility::writeToLog($exc);
         }
     }
     return $ok;
 }
Exemplo n.º 2
0
 /**
  * Log database error
  * @param type $link
  */
 public static function logMySQLError($link)
 {
     $error = mysqli_error($link);
     if (!empty($error)) {
         UserUtility::writeToLog(new Exception($error));
     }
 }