Reply to Re: [PHP] Meta HTTP refresh problem

Your name:

Reply:


Posted by Josh Whiting on 03/25/05 18:22

> 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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация