Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1.     if (isset($_POST['user']) && isset($_POST['pass'])){
  2.  
  3.         $user = htmlspecialchars($_POST['user']);
  4.         $pass = htmlspecialchars($_POST['pass']);
  5.  
  6.         if ($user == "" || $pass =="" || $user == " " || $pass ==" ")
  7.         {
  8.             echo "fail - Empty user or pass";
  9.             return;
  10.         }else{
  11.            
  12.             $query = mysqli_query($link, "SELECT * FROM accounts WHERE username ='$user' AND password =PASSWORD('$pass')");
  13.             $counter = mysqli_num_rows($query);
  14.  
  15.             if ($counter == 0){
  16.                 echo "fail";
  17.             }
  18.             else
  19.             {
  20.                 session_start();
  21.                 $_SESSION['username'] = $user;
  22.  
  23.                 echo "success";
  24.             }  
  25.  
  26.         }
  27.  
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement