'Header does not refresh after adding #reply

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?



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1