Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.75 KB | None | 0 0
  1. require_once("inc/config.php");
  2. class database
  3. {
  4.     function database_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db)
  5.     {
  6.         global $mysql_connectionid;
  7.        
  8.         global $mysql_host;
  9.         global $mysql_user;
  10.         global $mysql_pass;
  11.         global $mysql_db;
  12.        
  13.         $this->mysql_host = $mysql_host;
  14.         $this->mysql_user = $mysql_user;
  15.         $this->mysql_pass = $mysql_pass;
  16.         $this->mysql_db = $mysql_db;
  17.        
  18.         $this->connect = @mysql_connect($this->mysql_host, $this->mysql_user, $this->mysql_pass);
  19.        
  20.         if (!$this->connect) die ("Nem lehet csatlakozni a MySQL kiszolgálóhoz!");
  21.        
  22.        
  23.         if ($mysql_connectionid == NULL)
  24.         {
  25.             $mysql_connectionid = $this->connect;
  26.         }
  27.         @mysql_select_db($this->mysql_db, $this->connect) or die ("Nem lehet megnyitni a ".$mysql_db." -t: " .mysql_error());
  28.     }
  29. }
  30.  
  31. class loginc
  32. {
  33.     function login($username,$password)
  34.     {
  35.         global $sessionid;
  36.        
  37.         $this->username = $username;
  38.         $this->password = md5($password);
  39.        
  40.         if (!is_object($sql)) $sql = new database;
  41.         $sql -> database_connect($mysql_host,$mysql_user,$mysql_pass,$mysql_db);
  42.         $sql -> database_select('users','username, password','Username=\''.$this->username.'\' and Password=\''.$this->password.'\'');
  43.         $row = $sql -> database_fetch();
  44.        
  45.         if ($row)
  46.         {
  47.             $sql -> database_update('users','Session_Id="'.session_id().'"');
  48.             $sessionid = session_id();
  49.             return $sessionid;
  50.         }else
  51.         {
  52.             return USER_LOGIN_ERROR;
  53.         }        
  54.        
  55.         $sql -> database_close();
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement