Hi all I have a search form which is using the post method and it is redirecting the results into a div on a another page but when I refresh the page I get this confirm form resubmission dialog box and I was just wondering to know how can I disable this thanks.
I always use a header('location:http://url'); exit(); after a page use a POST. If you refresh it will not re-execute or ask for form resubmission. But you need to pass data to the next page, like with sessions.
Related
I have a web page that loads all the data from a mysql database called datalist.php
From this page I can edit record by record with a button that redirects you to an editdata.php page adapted to the fid of the record.
Once edited as they want to see the changes, I don't redirect them to the main one letting them see the changes and simply clicking back or with a button they return to the datalist.php without any problem.
The button is this
echo "<p id='parrafo'><a style='padding:1px 20px'class='button rounded-0 primary-bg text-white w-0 btn_1 boxed-btn' href='javascript:history.back() '><--</a></p>";
PROBLEM
I added a search engine where the displayed data can be filtered.
When they use the search engine from datalist.php, I direct them to a page called search engine.php where, through a post method, I store what they are looking for in a variable and the data that users want appears.
But when they edit a filtered record, it is edited without problems, but when they go back, they return to the search engine.php and the message appears:
"Confirm form resubmission In order to display correctly, this web page needs the data you entered earlier. You can submit that data again, but that will cause the page to repeat all previous actions. Press Reload to submit the data and display the page.
Hit the page refresh button to resubmit the data needed to load the page."
Of course, if they update, they come back when the filtered data comes out.
Isn't there any way to store the variable used in the search so that when I go back I don't get this error or any solution??
simple! when user will submit form for that variable instead of making post request
option1: just use get request __url__?variable=... but this will not remember the variable when you go back
option2: store the variable in the cookie and just go to next page (eg. window.location.href = '...';). and in next page access the cookie from php.
If you are wanting to show the form to the user as a confirmation, but without the possibility of another post, then remove the form element and the button. Display all other boxes as they are (with the values populated from the POST array).
And display another message telling them that it has been successful.
You are using PHP, you can achieve this easily with it. If you are unsure, then post a short version of your code in a separate question.
i have a form. In the action field i have given a page location where the control should redirect after submit. But i want to redirect to multiple page after submit. And the next page should open in new tab. I know about target_blank option. I just want to know how to redirect to multiple pages after submit. Thank you.
You can use this script in your submit form page
<script>
window.open('link','_blank');
</script>
What do you mean by redirect?
Do you want the submit button to send form data to two pages?
If yes this can be achieved by using session variables and opening a new window on the redirected page.
1) save the form data in session variables.
2) load the 1st page
3) use php script or you can use window.open("url") in the 1st page to redirect to a new page on a new tab.
I am wondering if it is possible to to resubmit a form with a button click that calls up a javascript command.
So this is basically what I'm trying to do -
page 1: form; action = page2.php
page 2: generate a randomized list according to parameters set by page 1
I would like to place a button on page 2 so that on click, it would be as if the user has hit F5, and a new list would be generated with the same parameters.
I found a lot of help on Google with people trying NOT to get this to happen, but I'm not sure how to actually get it to happen.....
Thank you!
You could use location.reload(true); to refresh the page.
<button onclick="location.reload(true);">refresh</button>
you only need to use. location.reload() instead of location.reload(true). since this will not disable caching for the reload but using true as the parameter will.
here is the reference. How to refresh a page in jquery?
EDIT: why not just use hidden input field and preserve the values and fetch it anytime you want to?
I'm using form in a project. In my form, when I click on submit button, the values are submitted properly but after submit if I refresh the page the existing values are inserted again without clicking on button. Please help me out how to submit the button value only on button click not on page refresh.
Use a redirect after page submit to a thank you page.
Header('location: thankyou.php');
exit();
Use the post-redirect-get pattern. http://en.m.wikipedia.org/wiki/Post/Redirect/Get
This means you use POST method on the form, and in the response script you redirect the user to a different page with the location header.
There is a good answer to your question here: How to avoid duplicate when a user click the "refresh" button of his browser?
Hi I am using php and i want to submit form on onclick event of radio button.
when form submission is done, than after I want to reload my page.
Means first form is submitted and after form submit I want to reload my page again.
Is it possible?
I have tried it with javascript but not get any idea how to do it..
Thanks in advance.
header('Location: http://url.to/reload');
exit;
Make sure to do this before any output on that page otherwise you'll get an error about headers already having been sent.