Advertisement
blackmind

Untitled

Feb 15th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2.  
  3. include_once 'config.php';
  4.    
  5.    
  6.     $username = $_POST["username"];
  7.     $password = $_POST["password"];
  8.    
  9.    
  10.                  if(mysqli_connect_errno())
  11.                  {
  12.                      $error = "1: Connection failed";
  13.        
  14.                  }
  15.  
  16.     $namecheckquery = "SELECT * FROM users WHERE username='". $username ."' AND password= '". $password ."'" ;
  17.     $namecheck = mysqli_query($con, $namecheckquery) or die ($error="2: Username check failed");
  18.     $row = mysqli_num_rows($namecheck);
  19.     $existinginfo = mysqli_fetch_assoc($namecheck);          
  20.                 if ($row == 1)
  21.                 {  
  22.                     session_start();
  23.  
  24.                    
  25.                     $_SESSION['username'] = $username;      
  26.                     $_SESSION['loggedin'] = true;
  27.                     echo $existinginfo["usertype"];
  28.                    
  29.                 }
  30.                 else
  31.                 {
  32.                     $error = "Username or Password is invalid";
  33.                 }
  34.    
  35.     mysqli_close($con);
  36.    
  37.  
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement