RE: [PHP] Re: authentication help

From: Date: Fri, 26 Oct 2001 04:52:53 +0000
Subject: RE: [PHP] Re: authentication help
Groups: php.general 
Request: Send a blank email to php-general+get-72388@lists.php.net to get a copy of this message
If you wanted to check for more than one username/password set, then extend this line if ($userid == "somename" && $password == "somepassword") { to something like if (($userid == "somename1" && $password == "somepassword1") || ($userid == "somename2" && $password == "somepassword2") || ($userid == "somename3" && $password == "somepassword3")) { Martin -----Original Message----- From: Gaylen Fraley [mailto:gfraley5@earthlink.net] Sent: Friday, October 26, 2001 2:01 PM To: php-general@lists.php.net Subject: [PHP] Re: authentication help Here would be one of many ways. This assumes that login.php and index.php are in the same directory. login.php <? if (isset($userid)||isset($password)) { if ($userid == "somename" && $password == "somepassword") { echo "YAY! You did it!"; exit; } header("Location: index.php"); exit; } ?> <html> <body> <form action="<?=$PHP_SELF?>" method=post> <table align=center border=2> <tr><td>User <td><input name=userid></tr> <tr><td>Password <td><input type=password name=password></tr> <tr><td colspan=2 align=center><input type=submit value=Submit> </form> </body> </table> </html> -- Gaylen gfraley5@earthlink.net http://www.gaylenandmargie.com PHP KISGB v2.1 Guestbook http://www.gaylenandmargie.com/phpwebsite "Norman Zhang" <nzhang@arkon-group.com> wrote in message news:001701c15cd8$a7acb710$6ddbb5d0@arkon.bc.ca... > Hi, > > Would someone please give me a few pointers on how to generate a simple PHP > to check for user's name and password before directing to a directory? > > e.g., I have a index.php with a form where I have action="login.php". How > would I write login.php to check username and password if I have them hard > coded in login.php and if authentication fails the user is directed back to > index.php? Is this safe? > > Regards, > Norman > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#72388) next »