Page 1 of 1

Displaying error message after redirecting the user

Posted: Sat Mar 28, 2009 4:40 pm
by lawillas
Hello everyone....i've been battling with this problem for a while now....I created a login script....everything works well except when i want to display error messages to users after they login with wrong values

when i try to do something like this :
if(mysql_num_rows($query) = 0) {
header("Location : login.php?muta=0&ml=".$_POST['username']);
echo "Invalid login detail";
exit();
}
the above code does display muta=0&ml=..'the username' on the URL but does'nt display the error message, but when i removed the line header ("Location : login.php?muta=0&ml=".$_POST['username']); it displayed the error message.

I need help on this as soon as possible.

Re: Displaying error message after redirecting the user

Posted: Sat Mar 28, 2009 5:24 pm
by deejay
it's because the user is being sent away before they get the "Invalid login detail"

That'll need to go on the 'login.php' page that your sending them to if you want them to see the message.


'

Re: Displaying error message after redirecting the user

Posted: Sun Mar 29, 2009 5:13 am
by lawillas
@deejay i dont quite understand wat u saying.....maybe u try nd show me an example

Re: Displaying error message after redirecting the user

Posted: Sun Mar 29, 2009 12:54 pm
by tech603

Code: Select all

if(mysql_num_rows($query) = 0) {
header("Location : login.php?muta=0&ml=".$_POST['username']);
echo "Invalid login detail";
exit();
}
What he is saying that in the above code your sending the user back to the login page before you echo out the error message. The easiest way to accomplish what you want is possibly using a meta refresh tag with your instead of using a header redirect, this will allow the page to echo the page message for the designated set time and then redirect.

<meta http-equiv="refresh" content="5;url=http://example.com/" />

Hope that helps