Password Protector

By F*U*R*B*Y* on Feb 17, 2006

just upload it to the top of the page that you want to protect, this page MUST be saved as .php

and just so no one else pm's me saying they don't know the password or username Code has been updated and change everything that says CHANGEME. ;)

<?
$infotext            ="Registered "; // The text that's displayed in the logon window
$loginname           ="CHANGEME";  // The login name for the secured page
$password            ="CHANGEME";    // The password for the secured page

    if ( (!isset($PHP_AUTH_USER)) || ! (($PHP_AUTH_USER == $loginname) && ( $PHP_AUTH_PW == "$password" )) ) {
        header("WWW-Authenticate: Basic entrer=$infotext");
        header("HTTP/1.0 401 Unauthorized");
        error("Access Denied");
    }
?>

Comments

Sign in to comment.
Lenooox   -  May 30, 2011

i got it :)

 Respond  
Lenooox   -  May 28, 2011

and how do I add my files(own php)? :$

 Respond  
Hawkee   -  Feb 17, 2006

As a general rule, you should never assume register_globals is enabled. In which case you need to reference the $_SERVER variables like this: $_SERVER[\"PHP_AUTH_USER\"]

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.