# \[php\] Login problem

**URL:** <https://forum.kirupa.com/t/php-login-problem/102507>\
**Category:** Uncategorized\
**Created:** [February 24, 2004, 3:26pm UTC](https://forum.kirupa.com/t/php-login-problem/102507 "2004-02-24T15:26:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![StudentInTheArt](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@StudentInTheArt](https://forum.kirupa.com/u/StudentInTheArt)\
**Post date:** [February 24, 2004, 3:26pm UTC](https://forum.kirupa.com/t/php-login-problem/102507/1 "2004-02-24T15:26:56Z")

</div>

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!
```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 25, 2004, 2:57pm UTC](https://forum.kirupa.com/t/php-login-problem/102507/2 "2004-02-25T14:57:05Z")

</div>

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\>

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 25, 2004, 4:07pm UTC](https://forum.kirupa.com/t/php-login-problem/102507/3 "2004-02-25T16:07:49Z")

</div>

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

```php

<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>

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 25, 2004, 4:12pm UTC](https://forum.kirupa.com/t/php-login-problem/102507/4 "2004-02-25T16:12:56Z")

</div>

Aha. looks like you got an extra “)”

```php

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();
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 25, 2004, 4:19pm UTC](https://forum.kirupa.com/t/php-login-problem/102507/5 "2004-02-25T16:19:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 25, 2004, 4:26pm UTC](https://forum.kirupa.com/t/php-login-problem/102507/6 "2004-02-25T16:26:13Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 25, 2004, 6:04pm UTC](https://forum.kirupa.com/t/php-login-problem/102507/7 "2004-02-25T18:04:44Z")

</div>

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