We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Login page problems
Topic Started: Jun 27 2005, 04:52 PM (259 Views)
blakeo_x
Member Avatar
I cant believe its not PHP!
[ *  *  * ]
I have this page where two people can log in to view this other page. Im not using a database to check the name/password since its only two people. Instead, Im storing the combinations in an array. The arrays look like this:

Code:
 
$user_data[0] = "blakeo_x, blah";
$user_data[1] = "admin, passgoeshere";


The login page submits the form to the PHP file. The form contains two fields: user and password. The PHP file puts the two together so it can be compared to $user_data. So, the entire block of code that is really giving me problems looks like this:

Code:
 
$user_data[0] = "blakeo_x, blah";
$user_data[1] = "admin, passgoeshere";

$user_input = $_POST[user] . ", " . $_POST[password];
for($i=0; $i<count($user_data); $i++)
{
 if ($user_input == $user_data[$i])
 {
  $display = "<b>Thank you</b><p>You are being logged in. Please wait...";
  break;
 }
}


Now, the problem is the PHP code above isnt making a correct comparison for some reason. Even when the correct user/password combination is given, it isnt executing the if statement. Why is this? (I hope I gave enough info and I wasnt too confusing ;) )
Offline Profile Quote Post Goto Top
 
kingy
1 in 10 people understands binary, the other 1 doesn't
[ *  *  *  *  *  * ]
try using quotes in your array variables, like $array['variable']
Offline Profile Quote Post Goto Top
 
solinent
Member
[ *  *  * ]
Here:
Code:
 

$user_data[0] = "blakeo_x, blah";
$user_data[1] = "admin, passgoeshere";

$user_input = $_POST["user"] . ", " . $_POST["password"];
for($i=0; $i<count($user_data); $i++)
{
if ($user_input == $user_data[$i])
{
 $display = "<b>Thank you</b><p>You are being logged in. Please wait...";
 break;
}
}
Offline Profile Quote Post Goto Top
 
blakeo_x
Member Avatar
I cant believe its not PHP!
[ *  *  * ]
Ok, thanks. Problem solved
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply