Refresh page once on load

Hi,

I am working on a web form built with HTML-PHP. It is like an options/settings page and it returns the same page when it is submitted. The form has a section that controls the style with 4 radio buttons (there are four styles). When the page first loads, one of the four radio buttons is checked by default (i.e., style 1 is selected). Then I select another style by clicking on its radio button and submit the form. When the page loads, it still shows the previous radio button as checked, but when I refresh the page it shows the second radio button checked as it should. It is the same with checkbox elements too. So, I don’t know if there is another solution to this but I thought that it might be related to cache and automatically refreshing the page for once would be a good idea. I found a couple of examples using some meta tags but they didn’t work.

If the above paragraph was a bit complicated, my question simply is “how can I refresh a page on load once?”. Thanks for any ideas.

Hi nayen. It’s not quite clear to me what situation you are describing, but it sounds like JavaScript might help you a bit. Can you post a link to an example?

Hi Ralph. I know it is difficult to understand the issue without seeing the code but this is a private project and I can’t post its code here.

I am just asking if you needed to refresh the page for once on load how would you do it? I found a lot of examples such as

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

but they didn’t work. I also went through the first three pages of Google for “refresh page once on load” type of queries but couldn’t found a working solution.

By the way, the refresh should be done only if the form button (update) is submitted.

EDIT: Ok, I found something that seems to be working. It might not be the best solution but I will use it until I find a better solution. What I am doing instead of a page refresh is that I am sending the visitor to the exact same form page using the following redirection (after the button is submitted) so that the form page loads as if it was refreshed updating radio button and checkbox selections:

header('Location: edit.php?id=$user_id');

edit.php?id=$user_id is where the form is located and populated with user’s information. The above solution doesn’t use JavaScript and it doesn’t make any changes in the URL, hence it seems to be a good one at this time.

UPDATE: What I did above now kills the error handling because redirection loads the page while destroying set variables. It seems I should forget about refreshing the page and look for an answer to why radio buttons and checkboxes don’t update after form submission. I will try to ask it again with giving code examples on another post because now I understand that it is not exactly related to refreshing a page.