Posted By

hced on 11/28/07


Tagged

password protect lock protection restriction


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

vali29
fackz


Single-Page Password Protection


 / Published in: PHP
 

URL: http://www.phpmac.com/articles.php?view=242

Makes a password protection system for single webpages.

  1. <html>
  2. <head>
  3. <title>Private Page</title>
  4. </head>
  5. <body>
  6.  
  7. <?php
  8. $password = "phpmac";
  9.  
  10. if (!isset($_POST['submit'])) {
  11. ?>
  12. <form action="" method="POST">
  13. Enter the Password: <input type="password" name="password"><br>
  14. <input type="submit" name="submit">
  15. </form>
  16. <?php
  17. } else {
  18.  
  19. if ($_POST['password'] == $password) {
  20.  
  21. ?>
  22.  
  23. Secret content!
  24.  
  25. <?php
  26. } else {
  27. ?>
  28.  
  29. <form action="" method="POST">
  30. Enter the Password: <input type="password" name="password"><br>
  31. <input type="submit" name="submit">
  32. </form>
  33.  
  34. <?php
  35. }
  36. }
  37. ?>
  38.  
  39. </body>
  40. </html>

Report this snippet  

You need to login to post a comment.