Problem while refreshing a page
Showing comments 1 to 8 of total 8 on page 1 of 1
jasonstedyRank: 155
tsanand129Rank: 23
can you paste the code over here.
maybe that can help in solving this?
robinalexRank: 1
User shouldn’t be refreshing the page after the submission. (The page needs to be designed in such a way that the user don't have to use any browser functionality for page navigation)
You have to generate the page in server with new content and send to user after submission.
Code has to be like:
<?php
//check if there is any input values submitted by user
//if input values are there then process the data
//else skip this section
?><!-- html code for form/static data -->
<?php
//php code for dynamic page content
?><!-- html code for form/static data -->
jasonstedyRank: 155
I see your point. But is there no way that i can allow the user to refresh the page without having to resubmit?
tsanand129Rank: 23
try 'unset($a);' at the beginning of the page
e.g:
<?php
if(isset($a))
{
unset($a)
}
?>
robinalexRank: 1
The error message which you are getting is a client side error message (browser error message). I am not able to understand the use of client side refresh in a web application.
However, I think the following method works for you.
1. Let Page1.php is your page in which user submits input
2. You can do the processing in page2.php after submit. (You can define action in page1.php form as page2.php)
3. Once you process the data in page2.php you can redirect user to page1.php
Sample code:
page1.php
<?php
//some php code
?>
<!-- some html code --><form name="frmName" id="frmName" action="page2.php" method="post">
<!-- controls in form -->
</form><?php
//some php code
?>
<!-- some html code -->
page2.php
<?php
//get the inputs from submitted form
//process the data
header("Location: page1.php");
//syntax: header("Location: [URL]") - this loads [URL] mentioned
?>
Now the page will be refreshed without any action from user and there won’t be any error messages in client side.
cerulean...Rank: 3
This is a common design pattern that you are trying to reinvent. Please read the following wikipedia article first. If you are still running into problems, please post back and we'll help you out.
http://en.wikipedia.org/wiki/Post/Redirect/Get
In case you're lazy, this is the summary: You need to send a 303 response code instead of 302 to remove that warning. So once you finish processing POST data, use the following command to redirect to a new page. Pressing refresh button afterwards should not throw a warning.
header( 'Location: your_success_page.php', true, 303 );