• Welcome to The Cave of Dragonflies forums, where the smallest bugs live alongside the strongest dragons.

    Guests are not able to post messages or even read certain areas of the forums. Now, that's boring, don't you think? Registration, on the other hand, is simple, completely free of charge, and does not require you to give out any personal information at all. As soon as you register, you can take part in some of the happy fun things at the forums such as posting messages, voting in polls, sending private messages to people and being told that this is where we drink tea and eat cod.

    Of course I'm not forcing you to do anything if you don't want to, but seriously, what have you got to lose? Five seconds of your life?

Password Protect A Page?

Kabigon

Yes We Can!! Obama Wins!
Around the internet, and on some webmaster communities, I have been seeing things like password protected pages. That way a page of a site could be entered so some staff members and friends could see it with the page(s) on the site. I'm not looking for a direct login script (although if someone could tell me how to do those too then it would be appreciated) but I just need one where you type in a password then it automatically redirects to the page.

Thanks in advance.
 
Depends on what your environment is. If all you have available to you is JavaScript, use something like this.

If you have PHP, something like this would do

PHP:
<?php
$logins = array(
             "user" => "password",
             "user2" => "anotherpassword",
            );

if ($logins[$_SERVER['PHP_AUTH_USER]] != $_SERVER['PHP_AUTH_PW'])) {
    header('WWW-Authenticate: Basic realm="Place"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Text to send if user hits Cancel button';
    exit;
} else {
    echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
    echo "<p>You're in the private page!</p>";
}
?>
 
Back
Top Bottom