Page 1 of 1

[SOLVED] Multiple user names through PHP

Posted: Sat Mar 19, 2005 7:10 pm
by Fusioned
Ok this is just for fun so ignore the insane security risks! Now, I want to be able to have multiple usernames login with one password. This is a php script I called CheckUser.php that is processed on a HTML page through a form.

Code: Select all

<?php
if (($username = "Vince" OR "JC" OR "Fusioned" OR "Test") &&
($password == "test")) {

header ("Location: mainframe.php?username=$username");

exit;
}
else {

print ("<center>Error logging in. Please try again.<BR></center>\n");

}

?>
The OR function works fine, but the problem is, when they login, I have this:

Code: Select all

Hello $Username! Good to see you again!
basically and it ALWAYS comes up as the first one...first one being Vince. Id rather use something else besides OR too....any suggestions or what I could do? Thanks!


feyd | Please review how to post code using

Code: Select all

and

Code: Select all

tags. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Sat Mar 19, 2005 7:20 pm
by hawleyjr
On mainframe.php add this line:

Code: Select all

<?php

$Username= &$_GET['username'];

?>

Posted: Sat Mar 19, 2005 8:13 pm
by Burrito
how are you echoing "hello $username...."?

the $username needs to be outside the quotes like this:

Code: Select all

echo "hello ".$_GET['username']." how are you";

Posted: Sat Mar 19, 2005 8:34 pm
by hawleyjr
Burrito wrote:how are you echoing "hello $username...."?

the $username needs to be outside the quotes like this:

Code: Select all

echo &quote;hello &quote;.$_GET&#1111;'username'].&quote; how are you&quote;;
Only if you are using single quotes.

Code: Select all

echo 'Hello $username';//Does not echo variable
echo "Hello $username"; //Will print

Posted: Sat Mar 19, 2005 9:06 pm
by feyd
*cough* line 2.

Posted: Sun Mar 20, 2005 1:11 am
by Fusioned
yeahh...this isn't solving the problem. I need a better way of listing multiple Usernames or something that isnt SQL based (for now). No matter what I echo or print, I always get Hello Vince. None of the other 3 usernames will ever appear and replace Vince. Whats the best route to go?

Posted: Sun Mar 20, 2005 1:14 am
by John Cartwright
you are always getting Vincent because you are not using the wrong comparison operator..

=

is not the same as

==

Code: Select all

if ($username == "Vince" ) ...
is the correct format

Posted: Sun Mar 20, 2005 1:23 am
by Fusioned
Phenom,


Wow. That did the trick!!! I cant believe I didnt notice that! Thanks for picking that up. I owe you one!