You are here: Re: How to set the username/password when using http authentication? « PHP Language « IT news, forums, messages
Re: How to set the username/password when using http authentication?

Posted by Els on 03/09/07 09:07

Rik wrote:

>> But how/where do I preset a username & password?
>> (yes I'm a total noob :-) )
>
> Use one preset username & password in a file:
> <?php
> $username = 'username';
> $password = 'password';
> if (!isset($_SERVER['PHP_AUTH_USER'])) {
> header('WWW-Authenticate: Basic realm="My Realm"');
> header('HTTP/1.0 401 Unauthorized');
> echo 'Text to send if user hits Cancel button';
> exit;
> } else {
> if($_SERVER['PHP_AUTH_USER'] != $username)
> echo 'Username incorrect:'.$_SERVER['PHP_AUTH_USER'].',
> expected:'.$username;
> if($_SERVER['PHP_AUTH_PW'] != $password)
> echo 'Username incorrect:'.$_SERVER['PHP_AUTH_PW'].',
> expected:'.$password;
> }
> ?>
>
> Take it from there, add the md5 in later, then try it in Joomla, the try
> to use the database.

Thanks Rik, I've tried that in a local page, and it works. That is, it
lets me in regardless of whether I get the password right or not, the
difference is the error message if I got it wrong. How do I get a new
login prompt if the details are incorrect, and also, how do I "log
out" again? I can't make two attempts in a row, it just keeps whatever
I filled out once as final...

--
Els http://locusmeus.com/

Now playing: David Bowie - Absolute Beginners

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация