I've got a section on every page of my site which allows the user to set a reminder. It loads the appropriate form on the page when the $addtracker variable is set in the url using:
$current_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";?>
Add reminder
It works on every page except pages which rely on POST data, such as a search results page. When the link is clicked on these pages, the POST data disappears and so I get 0 results in the search and $_POST data not found errors.
How can I reload the current page with the POST data intact?
You should use form with method="GET"
Do not use link , use form with button.
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 page called a.php . It has a form and submit data via POST to same file (a.php) . Page loads with no error. Then I click any link (b.php or b.html) on that page . it directs to any page as usual. Then when I click back button from b.php or b.html it does not show previous page.
Any help to solve this matter ?
Thanks
About Method
The $_POST Method used for SUBMITTING FORMS something Create or Modify it is a secure method.In other words POST is sending data to server from browser
FOR EXAMPLE
Creating Articles
Editing Articles
File Uploading
In your case you are getting values POST is not for getting values Use $_GET method for this
Why Document Expires ?
I taken this Image from wikipedia.
Why Browser Do this?
It is because it prevent from duplicate submission.
For Example : On any shopping site there are payment options user buy a product and pay for it , now if he/she(user) refresh page again the payment done two times .
according to your question, page a.php is submitting data (post) to the page itself, so if you go to other page and then want to back again to page a.php (by clicking the back button on browser) it causes document expired because when you click it you are not submitting any data (post) to page a.php.
I have a page that offers the user results. From that page there are additional sort options and advanced search options that are submitted by POST by AJAX to a script and the output is inserted into a div using jquery.
Once the user clicks one of the results, they are redirected to the details page. When I click back from that page it doesnt load says form submission error.
Not sure what to be looking for all the stuff I have seen is for when there are simply multiple ajax pages in one page.
I have a form which once the Submit button is pressed, it goes to a blank page and returns any error messages on that blank page. However I have a website template and I wish that my script is run, and returns the the page which did the action POST and puts any error messages on that page.
Example of what is happening:
PAGE REQUESTS POST ----> SCRIPT RUNS ---> RETURNS ERROR MESSAGE
What I want it to do is:
PAGE REQUESTS POST ---> SCRIPT RUNS ----> GOES TO THE PAGE WHICH REQUESTED POST ----> SHOWS ANY ERROR MESSAGES WHICH THE SCRIPT PICKED OUT.
Sure you can, just set the Action of your form to the current page. Then the $_POST will contain all the values the user filled in the form.
You have two options. I assume your are going to a blank page, because your POST goes to a PHP script different from the page it is posting from.
Option 1 - Post to the same PHP page as the page your are posting from.
Option 2 - Once you have posted, and generate an error, redirect back to the page, with the errors stored in a session, or a cookie, so that they can be rendered on the original page.
Assuming that the page containing the request form is also able to display the error messages, set the form attribute to the url of the page containing the form (as TJHeuvel noted) or just make action attribute empty, e.g, <form action="">.
After going to blank page store all the posted variables in your variable say $get with syntax param1=value1¶m2=value2 and so on...and redirect back by header("Location: back.php?$get"); and in your main page by $_GET echo all the vars
i have a search form page, which takes me to reslutant page and show me so me some records acc to search criteria. And by clicking on any of the record it takes me to its details page.
now there i had placed a back button on which i had used js script history.go(-1) to go back to the resultant page while showing the same results i had searched.
but instead it 1st show "CONFORM FORM RESUBMISSION" and after i press F5 then it show me the particular records.
Sounds like your search results page is a POST page. By default those are not cached by the browser, which is why you get that "form resubmit" stuff - the POST has to be reperformed and the page regenerated. Changing it to a GET will eliminate that.
Send you're search form data using GET , then it whont ask you to confirm form resubmission .