[php] Login problem

Hi guys,
I’ve been checking out useful things on kirupa for a while now, and I was wondering if any of you might know something about html or php. I’m currently studying the subject & its really irritating. I’ve tried several other sites which might have something but they didnt really offer much help. Please if you know something about html or php programming post here & i’ll pester you sometime soon.

                                                                                 Thank You!

i was merely using dude & dude’s pass as examples they’re not the actual thing

I have about 30 or 40 people in the list & i didnt want to to put all of them on there.

this is the short version with just 3 users

<html>
<head>
<title>Check</title>
</head>
<body>
<center><font size = “7” face = “Still Time” color = “black”>Verification Processed…
<hr>
<br>
<?php

$usernames[] = “Jimmy”;
$passwords[] = “Access”;
$messages[] = “Welcome Jimmy”;

$usernames[] = “Timmy”;
$passwords[] = “Password”;
$messages[] = “Welcome Timmy”;

$usernames[] = “hobart”;
$passwords[] = “c2aBle3”;
$messages[] = “Welcome Hobart”;

if((empty($HTTP_POST_VARS[‘username’]))
||
(empty($HTTP_POST_VARS[‘password’]))){
echo “Invalid, Try Again”;
exit();
}

$matchfound = false;

for($count = 0; (($count < count($usernames)) && ($matchfound == false)); $count++)
{
if($HTTP_POST_VARS[‘username’] == $usernames[$count] && $HTTP_POST_VARS[‘password’] == $passwords[$count])
{
echo “Welcome,” + $HTTP_POST_VARS[‘username’];
}
}
?>
</body>
</html>

Its easier to see if you use the: [ php ] tags.


<html>
<head>
<title>Check</title>
</head>
<body>
<center><font size = "7" face = "Still Time" color = "black">Verification Processed...
<hr>
<br>
<?php

$usernames[] = "Jimmy";
$passwords[] = "Access";
$messages[] = "Welcome Jimmy";

$usernames[] = "Timmy";
$passwords[] = "Password";
$messages[] = "Welcome Timmy";

$usernames[] = "hobart";
$passwords[] = "c2aBle3";
$messages[] = "Welcome Hobart";

if((empty($HTTP_POST_VARS['username']))
||
(empty($HTTP_POST_VARS['password']))){
echo "Invalid, Try Again";
exit();
}

$matchfound = false;

for($count = 0; (($count < count($usernames)) && ($matchfound == false)); $count++)
{
if($HTTP_POST_VARS['username'] == $usernames[$count] && $HTTP_POST_VARS['password'] == $passwords[$count])
{
echo "Welcome," + $HTTP_POST_VARS['username'];
}
}
?>
</body>
</html>

Aha. looks like you got an extra “)”


if((empty($HTTP_POST_VARS['username']))
||
(empty($HTTP_POST_VARS['password']))){
echo "Invalid, Try Again";
exit();
}

//should be:

if (empty($HTTP_POST_VARS['username']) || empty($HTTP_POST_VARS['password'])) {
echo "Invalid, Try Again";
exit();
}

Thanks SeiferTim!!!

But that isn’t the problem anymore.

I just need to know how to print out the message corresponding with the user. It prints out Invalid, Try again if you dont enter that stuff.
But if you enter correctly it just outputs a 0.

would i have to group the if statement in the for loop?

Just guessing, but I think its still checking for a match, regarless of whether or not it finds one or not… so if you put in the first user/pass, then it checked all 3, and then stops after the third one, thing thinking there is no match…

how am i supposed to fix it then? is it possible to do this with a switch statement?