Guest User

Untitled

a guest
Feb 12th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. class User extends ActiveRecord {
  2. public static $table = "users";
  3. public static $key = "user_id";
  4.  
  5. public static function login($email, $password) {
  6. $users=self::getAll(" WHERE email = '$email' AND password = '$password' LIMIT 1");
  7. print_r($users);
  8. }
  9.  
  10. <?php
  11.  
  12. abstract class ActiveRecord {
  13. public static function getAll($filter="") {
  14. $instance = Database::getInstance();
  15. $conn = $instance->getConnection();
  16.  
  17. $pdo = $conn->prepare("SELECT * FROM ".static::$table." ".$filter);
  18. $pdo->execute();
  19.  
  20.  
  21. $res = $pdo->fetchAll(PDO::FETCH_CLASS, get_called_class());
  22.  
  23. return $res;
  24.  
  25.  
  26. }
  27.  
  28. <?php
  29. include("admin/config.php");
  30.  
  31. if (isset($_POST['inputEmail']) && !empty($_POST['inputEmail']) &&
  32. isset($_POST['inputPassword']) && !empty($_POST['inputPassword'])) {
  33.  
  34. $email = $_POST['inputEmail'];
  35. $password = $_POST['inputPassword'];
  36.  
  37. $user = User::login($email, $password);
  38. }
Add Comment
Please, Sign In to add comment