Hi bcrossb,
There are of course a number of ways you can work this, but for simplicity, you simply need to add another if statement to check for jim's login details.
Think about the logic of the page as opposed to the code:
Code:
- If the username and password equal bob's details
- Set as logged in
- Otherwise, deny access
We want to slot in a check for jim's details between checking bob and denying access:
Code:
- If the username and password equal bob's details
- Set as logged in
- Otherwise, if the username and password equal jim's details
- Set as logged in
- Otherwise, deny access
To do this we can use the "else-if" statement:
Code:
if (($_SESSION['username'] == 'bob') and
($_SESSION['userpass'] == 'xxxxxxxxxx' )) {
$_SESSION['authuser'] = 1;
} else if (($_SESSION['username'] == 'jim') and
($_SESSION['userpass'] == 'yyyyyyyyyy' )) {
$_SESSION['authuser'] = 1;
} else {
echo 'Sorry, but you don\'t have permission to view this page!';
exit();
}
You can do this for any number of users. Just keep adding the else ifs....
Let me know if that doesn't make sense
Phil