Re: authentication help
| From: | Gaylen Fraley | Date: | Fri, 26 Oct 2001 04:00:39 +0000 |
| Subject: | Re: authentication help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-72381@lists.php.net to get a copy of this message | ||
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
>