Beispiel #1
0
 if (empty($formdata['username'])) {
     $errors['username'] = "******";
 }
 if (empty($formdata['password'])) {
     $errors['password'] = "******";
 }
 if (empty($errors)) {
     // since none of the form fields were empty,
     // store the form data in variables
     $username = $formdata['username'];
     $password = $formdata['password'];
     // create a UserTable object and use it to retrieve
     // the users
     $connection = connection::getInstance();
     $userTable = new UserTable($connection);
     $user = $userTable->getUserByUn($username);
     // since password fields match, see if the username
     // has already been registered - if it is then throw
     // and exception
     if ($user == null) {
         $errors['username'] = "******";
     } else {
         if ($password !== $user->getPassword()) {
             $errors['password'] = "******";
         }
     }
 }
 if (!empty($errors)) {
     throw new Exception("There were errors. Please fix them.");
 }
 // since the username is not aleady registered, cre