Exemplo n.º 1
0
 $formdata['password'] = filter_input($input_method, "password", FILTER_SANITIZE_STRING);
 //if any of the form fields are empty
 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.");
Exemplo n.º 2
0
 public function getAmount($type)
 {
     $b = connection::getInstance()->prepare("SELECT count(*) as count FROM {$type}");
     $b->execute();
     $resColumn = $b->fetchAll();
     if ($resColumn == null) {
         return null;
     }
     return $resColumn[0]["count"];
 }