i am working on a validation page that will validate a username and a password, coming from the login page. i have gotten the information to transfer pages but need some help on validating.
would i put the valid usernames and passwords in an array?
username and password validation
Moderator: General Moderators
-
mydingding
- Forum Newbie
- Posts: 2
- Joined: Thu Oct 23, 2003 10:07 pm
- Location: hawaii
The best way would be to store the usernames and passwords in a database and check against that..... but as you're new to PHP let's start with something a bit more basic.
After you have sent the username and password to a page for validation you might use something like this.....
After you have sent the username and password to a page for validation you might use something like this.....
Code: Select all
<?
$un = $_GET["username"];
$pw = $_GET["password"];
$accounts["Bob"] = "bobpassword";
$accounts["Jim"] = "jimbo2000";
$accounts["Sarah"] = "doggies";
$account_exists = false;
foreach($accounts as $username => $password)
{
if($username == $un && $password == $pw) $account_exists = true;
}
if($account_exists)
{
// Things are good. Code goes here
}
else
{
// The username and/or password is wrong. Code goes here
}
?>
Last edited by Gen-ik on Thu Oct 30, 2003 7:42 am, edited 1 time in total.
or in a database or a ldap-directory or ... 
start with http://www.evilwalrus.com/search.php?ca ... arch=login
start with http://www.evilwalrus.com/search.php?ca ... arch=login