Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 14th, 2012  |  syntax: PHP  |  size: 0.73 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. if(isset($_POST['submit']))
  3. {
  4. $username = $_POST['username'];
  5. if (file_exists($dirname)) {
  6. echo "Name already taken.";
  7. } else {
  8. mkdir($username, 0755);
  9. }
  10. fopen(".$username./.htaccess", "r+");
  11. $content = "AuthUserFile /.htpasswd\nAuthType Basic\n\nrequire user $username";
  12. file_put_contents(".$username./.htaccess",
  13. echo "Please <a href='$username'>click here</a> to login.";
  14. }
  15. ?>
  16. <!DOCTYPE HTML>
  17. <head>
  18. <meta charset="UTF-8">
  19. <title>Register</title>
  20. </head>
  21. <body>
  22. <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">
  23. Username: <input type="text" name="username"><br>
  24. Password: <input type="password" name="password"><br>
  25. <input type="submit" name="submit" value="submit">
  26. </body>
  27. </html>