[SOLVED] Multiple user names through PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Fusioned
Forum Commoner
Posts: 32
Joined: Tue Jan 18, 2005 10:43 pm
Location: Philadelphia, PA

[SOLVED] Multiple user names through PHP

Post 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]
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

On mainframe.php add this line:

Code: Select all

<?php

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

?>
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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";
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

*cough* line 2.
User avatar
Fusioned
Forum Commoner
Posts: 32
Joined: Tue Jan 18, 2005 10:43 pm
Location: Philadelphia, PA

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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
User avatar
Fusioned
Forum Commoner
Posts: 32
Joined: Tue Jan 18, 2005 10:43 pm
Location: Philadelphia, PA

Post by Fusioned »

Phenom,


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