Advertisement
jcoutie

login_fail

Nov 6th, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. /* NOTES:   Errors have been commented in line with header location commands.
  2.         Login.php uses $_GET['attn'] to load error message type and $_GET['u'] to reload username
  3.         all $_GET values work when typed manually into address bar      */
  4.  
  5.     <?php
  6. if (isset($_POST['verify'])){
  7.     $username = $_POST['username'];
  8.     $password = $_POST['password'];
  9.     $remember = $_POST['remember'];
  10. if ($username&&$password){ 
  11.     $login = mysql_query("SELECT * FROM users WHERE username='$username'");
  12.     while($row = mysql_fetch_assoc($login)) {
  13.         $db_password = $row['password'];
  14.         if (password($password) == $db_password) {
  15.             $loginok = TRUE;
  16.         } else {
  17.             $loginok = FALSE;
  18.         }
  19.         if ($loginok==TRUE){
  20.             if ($remember==TRUE) {
  21.                 setcookie("username",$username, time() + 7200);
  22.             } else if ($remember==FALSE) {
  23.                 $_SESSION['username']=$username;
  24.             }
  25.             header('Location: index.php');  //blank white screen
  26.             exit();
  27.         } else {
  28.             die(header('Location: login.php?attn=wl&u=',$username)); //no error or username
  29.         }
  30.     }
  31.    
  32. } else {
  33.     die(header('Location: login.php?attn=no&u=',$username)); //no username
  34. }
  35.  }
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement