cafreak

doRegister.php #1 [Mike M. tutorial]

Aug 17th, 2014
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.83 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:Username and/or password might be empty
  10. 2:Username is not alphanumeric OR haven't got the correct length
  11. 3:Password haven't got the correct length, or does not contact a-z A-Z 0-9 ! @ # $ % ^ & *
  12. 4:Username already in use
  13. 5:Registration Failed
  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 is valid
  25.         if($functions->check_password($password) == true){
  26.             //password is valid
  27.             if($functions->username_exists($username) == false){
  28.                 //remember this must be FALSE else the username already exists! <this is pretty much the only function that may return false in the register
  29.                 //username does not exist
  30.                 if($functions->register($username, $password) == true){
  31.                     //username and password is registered
  32.                     echo('<strong>Successfully Registered!</strong><br />You can now <a href="login.php">login</a>!');
  33.                 }else{
  34.                     //username and password could not be registered.
  35.                     header("Location: register.php?id=5");
  36.                     echo("Reloading...");
  37.                 }
  38.             }else{
  39.                 //username exists
  40.                 header("Location: register.php?id=4");
  41.                 echo("Reloading...");
  42.             }
  43.         }else{
  44.             //password is invalid
  45.             header("Location: register.php?id=3");
  46.             echo("Reloading...");
  47.         }
  48.     }else{
  49.         //username is invalid
  50.         header("Location: register.php?id=2");
  51.         echo("Reloading...");
  52.     }
  53. }else{
  54.     header("Location: register.php?id=1");
  55.     echo("Reloading...");
  56. }
  57.  
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment