954,093 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Password Protect without .htaccess

Any ideas on how i can password protect a folder on a website without using .htaccess files.

firefly81189
Newbie Poster
1 post since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

Use a simple PHP script with a static username and password and maybe a javascript prompt form, or standard HTML prompt form.

<?php
$username = "myusername";
$password = "mypassword";

if (!isset($_POST['submit'])) {
?>
<form method="POST" action="<?=$_SERVER['PHP_SELF']?>">
Username: <input type="text" name="username"><br/>
Password: <input type="password" name="password"><br/>
<input type="submit" name="submit" value="Login">
<?php
} else {
      if ($_POST['username'] == $username && $_POST['password'] == $password) {
            echo "<a href="privatepage.html">Click to continue...</a>";
      }
}
?>

Or something like that. Not very secure though. But works.

maddog39
Light Poster
39 posts since Oct 2007
Reputation Points: 10
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: