Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <?php
  2. ini_set('display_errors', 1);
  3. ini_set('display_startup_errors', 1);
  4. error_reporting(E_ALL);
  5.  
  6. class Login
  7. {
  8.     private $login;
  9.     private $password;
  10.  
  11.     public function __construct($login, $password)
  12.     {
  13.         $this->login = $login;
  14.         $this->password = $password;
  15.     }
  16.  
  17.     public function login()
  18.     {
  19.         if (empty($_POST['username']) || empty($_POST['password'])) {
  20.             echo 'wypelnij dane';
  21.         } else {
  22.             $connection = mysqli_connect("localhost", "root", "" , "football");
  23.             $result = mysqli_query($connection, "SELECT * FROM user WHERE username = '{$this->login}' and password = '{$this->password}' limit 1");
  24.             if (!$result) {
  25.                 die(" Error: " . mysqli_error($connection));
  26.             }
  27.             $check = mysqli_fetch_array($result);
  28.             var_dump($check);
  29.         }
  30.     }
  31. }
  32.  
  33. $user = new Login($_POST['username'], $_POST['password']);
  34. $user->login();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement