Re: Meta HTTP refresh problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Recently, during a rewrite of my login page, the Meta Refresh I am using 
> suddenly stopped working. I've tried using it by echoing it with php and 
> by just using it in HTML. I've also tried using a javascript redirect 
> with no luck either. Any thoughts on how to debug and what might be 
> holding me up?
[snip]
> //Test to see if you actually got to this part
> echo "You should be going somewhere!";
> echo "<META HTTP-EQUIV=REFRESH CONTENT=\"0;URL=main_page.php\">";
> } else {
> printLogin();
> echo "<br><center>Invalid username/password</center>";
> }

<META> tags have to go in the <HEAD> section of the HTML document.

this is an optional suggestion but, overall, one thing that would be
better is to determine (before you send any ouput) if the login was
correct or not, and if not, use an HTTP redirect:

if (bad login) {
  header("Location: http://mydomain.com/login.php?tryAgain=1";);
} else {
  header("Location: http://mydomain.com/mainpage.php";);
}

(the tryAgain=1 is to tell the script that you want to show a  
"login failed, please try again" message)

using a redirect instead of a meta refresh is more user friendly because
(1) it's faster since some browsers force a waiting period before the
refresh happens (as a usability feature), and (2) the user can use
back/forward without running into the "this page contains POST data, do
you want to resend it?" alert, which I avoid in my designs like the 
plague (always using a redirect instead of showing output as the result 
of a POST action).

HTH
/josh w

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux