PHP - Basic Login


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. if($_POST['user']) {
  3. if(($_POST['user'] == "Username1") && ($_POST['pass'] == "Password1")) header("Location: http://the page to go to.com");
  4. else if(($_POST['user'] == "User2") && ($_POST['pass'] == "Password2")) header("Location: http://the page to go to .com");
  5. else header("Location: error.htm");
  6. } else {
  7. ?>
  8. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  9. <html>
  10. <head>
  11. <title>php log in script</title>
  12. </head>
  13.  
  14.  
  15.  
  16.  
  17. <body>
  18. <br><br>
  19. <center>
  20. <font size= "6">Please Log In Below</font><br><br><br>
  21. <form action="<?=$PHP_SELF?>" method="post">
  22. <p>Username: <input type="text" name="user"/>
  23. Password: <input type="password" name="pass"/>
  24. <input type= "submit" value= "Log In"/></p>
  25. </form>
  26. </center>
  27. </body>
  28. </html>
  29. <?php } ?>

URL: http://www.dynamicdrive.com/forums/showthread.php?t=28358

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.