tags:

views:

363

answers:

1
+2  Q: 

Header Refresh

if (strlen($_POST['reply']) < 6) {
header("Refresh: 2; url=thread.php?id=$tid#reply");
die("The text you have entered is too short. Please write a longer text and try again.");
}

Why won't header refresh work when I add #reply? Gives a blank page. It works with header location though. Any idea?

+3  A: 

anything after hash sign (#) is a local part of the URL and shouldn't force refresh. Also, if you have #reply in the URL in browser and press enter again in address bar, the page is not refreshed, you are just taken to the #reply part (target) of the page.

Also note, you are breaking standards by not using full URL. You should be using: url=http://server.com/thread.php?id=$tid#reply

PS: I would recommend using Header("Location: xxxxxxxx"); you should put refresh in the META tag

dusoft