View Full Version : Password Protection

09-01-2006, 09:25 PM
I have an area of my site that I would like to password protect. I DO NOT want to use MySQL, but I would like to use flatfiles (preferably) or an xml file. However, the login does need to be a form, the username and password editable and the protection secure.
I know I have very specific requirements, but could someone please help?

09-01-2006, 09:28 PM
search on google there are loads of free ones :)

Lee Stevens
09-01-2006, 11:43 PM
Not sure if you wanted one at the top of the page, well here's one!

$username = "test";
$password = "test";

function authenticate() {
Header( "WWW-authenticate: basic realm=\"Protected\"");
Header( "HTTP/1.0 401 Unauthorized");
echo "You must enter a valid login ID and password!";

function CheckPwd($user,$pass) {
global $username,$password;
return ($user != $username || $pass != $password) ? false : true;

if(!isset($PHP_AUTH_USER)) {
elseif(!CheckPwd($PHP_AUTH_USER,$PHP_AUTH_PW)) {

09-03-2006, 04:49 PM
Thanks, but I have already searched google and don't want a premade script. Also, the login has to be changable and I don't think that storing it in a variable imbedded into a file is the best way.
Can anyone help?

09-03-2006, 05:12 PM
What kind of help are you looking for? You know if one of us were to write the code to make it work, that would be a pre-made script and you wouldn't be happy with that... so, just what is it you want us to do?

09-03-2006, 06:37 PM
The best way is to look at the pre-made scripts & then just customize it yourself. This way nobody knows what the script looks like.