Guest User

Untitled

a guest
Jan 22nd, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. <?php
  2.    
  3. class AuthenUser{
  4.     private $username;
  5.     private $password;
  6.     private $passmd5;
  7.  
  8.     public function CNX(){
  9.         mysql_connect('localhost', 'phobya_connect', 'amorderey1') or die(mysql_error() . "Couldnt connect to the server");
  10.         mysql_select_db('phobya_testing') or die(mysql_error() . "Couldnt select the Database" );
  11.     }
  12.    
  13.     public function __construct(){
  14.         $this->username = $this->filter($_GET['username']);
  15.         $this->password = $this->filter($_GET['password']);
  16.         $this->passmd5  = md5($this->password);
  17.     }
  18.    
  19.     public function filter($var)
  20.     {
  21.         $this->CNX();
  22.         $escaped = mysql_real_escape_string($var);
  23.         return preg_replace('/[^a-zA-Z0-9@.]/','',$escaped);
  24.     }
  25.  
  26.     public function verifyUser(){
  27.         $this->CNX();
  28.         $query = mysql_query("SELECT * FROM members WHERE email='{$this->username}' AND password='{$this->passmd5}'");
  29.         $num_rows = mysql_num_rows($query);
  30.             if($num_rows > 0){
  31.                 echo 'true';
  32.             }
  33.             else
  34.                 echo 'false';
  35.     }
  36. }
  37.  
  38. $AU = new AuthenUser();
  39. $AU->verifyUser();
  40.  
  41. ?>
Add Comment
Please, Sign In to add comment