Not a Member Yet,
Click here to Register
How do you like the new design?
It's cool, great job
[tally: 70%] 70%
It's okay
[tally: 20%] 20%
Its OK but I liked the old layout better
[tally: 0%] 0%
Please bring the old one back
[tally: 10%] 10%

votes: 10

ID: 87
Viewed: 5424
Added: Jun 24, 2004
Version: php4.1+
Snippet uploaded by: snippet
Written By: snippet
Demo: Sorry, no demo



User Rated at: 5 Stars5 Stars5 Stars5 Stars5 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

This brings up a password window where the user has to enter a username and password. it then checks with Mysql to see if the username and password are real (compares it to the original). it then will load a page for the user to see or it will bring it up the password box again.<br><br>put the following in a seperate php file and include it on all your protected files: <br>

this will not work work if your server is setup in cgi mode.

<!---Head--->
none

<!---Body--->


 <?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {

header('WWW-Authenticate: Basic realm="Login"');
header('HTTP/1.0 401 Unauthorized');
exit;

} else if (isset($_SERVER['PHP_AUTH_USER'])) {

$sql = "SELECT * FROM users WHERE username='".htmlentities($_SERVER['PHP_AUTH_USER'])."' and password='".htmlentities($_SERVER['PHP_AUTH_PW'])."'";
$result = mysql_query($sql);
$num = mysql_num_rows($result);

if ($num != 1) {
header('WWW-Authenticate: Basic realm="Login"');
header('HTTP/1.0 401 Unauthorized');
exit;
} else{
// show page you want them to see here

}

}
?>


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2017 snippetlibrary.com All Rights Reserved. Conditions