Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. if(isset($_SESSION['is_login']))
  5. {
  6.     header('Location:index.php');
  7.     exit;
  8. }
  9.  
  10. if(!empty($_POST))
  11. {
  12.     $query="SELECT * FROM staff WHERE username ='{$_POST['username']}' AND password ='{$_POST['username']}'";
  13.     $result=mysql_query($query);
  14.  
  15.    
  16.     if(is_array($result))
  17.     {
  18.         $_SESSION = $result[0];
  19.         $_SESSION['is_login'] = true;
  20.        
  21.            
  22.     }
  23.     else
  24.     {
  25.         $status = '<p style="background-color: red; color: white;">
  26.                     Invalid username / password</p>';
  27.     }
  28.    
  29. }
  30. ?>
  31.  
  32. <form action="login.php" method="">
  33.     <input type="text" name="username" value="">
  34.     <input type="password" name="password" value="">
  35.     <input type="submit" value="login">
  36. </form>
  37.  
  38. <?php
  39. if (isset($status))
  40.     echo $status;
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement