PHP Login won't redirect?

Soldato
Joined
30 Nov 2005
Posts
3,084
Location
London
Been racking my brains to get this PHP login working and have nearly got there. Just one problem left, for some reason if the username/password is wrong it's won't redirect.

Any ideas?

Cheers

if (!$rs->EOF)
{
if ($_POST["user"] == $User &&
$_POST["password"] == $Password)
{
session_start();
$_SESSION["Authorised"] = "Y";
header("Location: index.php");
}
else
{
header("Location: baduserpass.php");
}
}
 
Bump?

Despite my lack of knowledge I think we can assume it's ignoring the "else".

So it works if the user/password is correct but if they are wrong it does nothing.

Please help, I'm so close yet so far. ;)
 
Sorry for being such a "noob" as they say but how might I do this and why would it make a difference?

As it works fine if the user/password is right then I can't see why anything else would be wrong.

I'm convinced there is something wrong in my code attached at the top of this thread. But just can't work out what.
 
Thanks for the help guys but still no joy.

All the happens with whatever method I try is when you enter a wrong username/password just a blank page comes up, the page that has the PHP Validate code in it.

Basically it goes:

Login Page - Form input
Validate Page - Checks form input (code included in this thread)
Takes you to the Logged in Index Page- If user/password correct.
 
Problem solved!

I can't believe I didn't think of this earlier :mad:

I just stuck my original code into wrongpassword.php instead. So if the user gets there username/password wrong it just goes straight to wrongpassword.php, if it's right it redirects to index.php.

Easy work around!

Thanks for all the help though guys. :)
 
Back
Top Bottom