Advertisement
cafreak

doLogin.php #1 [Mike M. tutorial]

Aug 17th, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. <?php
  2. require("functions.class.php");
  3. $functions = new functions;
  4.  
  5. @$username = strip_tags($_POST['username']);
  6. @$password = strip_tags($_POST['password']);
  7.  
  8. /*WARNING LIST
  9. 1:wrong username + password combination
  10. 2:username is not found
  11. 3:username and/or password might be empty
  12. 4:username is not alphanumeric OR haven't got the correct length
  13. 5:password haven't got the correct length / or invalid characters
  14. */
  15.  
  16. //echo($functions->username_exists("admin"));
  17. //echo($functions->receive_password("admin"));
  18. //echo($functions->receive_salt("admin"));
  19. //echo($functions->equal_password("admin","password"));
  20.  
  21. if(!empty($username) && !empty($password)){
  22.     //username and password is filled in.
  23.     if($functions->check_username($username) == true){
  24.         //username exists
  25.         if($functions->username_exists($username) == true){
  26.             //username is alphanumeric and has the correct length(s)
  27.             if($functions->check_password($password) == true){
  28.                 //password has the correct length
  29.                 if($functions->equal_password($username, $password) == true){
  30.                     //username and password is correct
  31.                     echo("Successfully Logged In");
  32.                 }else{
  33.                     //username and/or password combination is incorrect!
  34.                     header("Location: login.php?id=1");
  35.                     echo("Reloading...");
  36.                 }
  37.             }else{
  38.                 //password haven't got the correct length or contains disallowed characters
  39.                 header("Location: login.php?id=5");
  40.                 echo("Reloading...");
  41.             }
  42.         }else{
  43.             //username does not exist
  44.             header("Location: login.php?id=2");
  45.             echo("Reloading...");
  46.         }
  47.     }else{
  48.         //username is not alphanumeric and/or haven't got the correct length(s)
  49.         header("Location: login.php?id=4");
  50.         echo("Reloading...");
  51.     }
  52. }else{
  53.     //username and/or password is not filled in.
  54.     header("Location: login.php?id=3");
  55.     echo("Reloading...");
  56. }
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement