Question

I have a HTML page with nothing but a form on that allows me to search a database and save the query results in an array. I then go through the array and echo out the results of each field in the table as plan text.

however if the page is reloaded the results of the last query just stay on the page until I submit a new query.

I want this text to disappear so the page looks like it does the first time it is opened/ before any text has been outputted to the page.

when I reload the popup 'do you want to resubmit form data appears'

Was it helpful?

Solution

You are seeing the search results again, because when you refresh the page you are submitting again the search form.

You can't avoid that as long as you stay on the same page.

OTHER TIPS

You can actually fix this.

Every time the page is loaded, generate a random number, and put that into a session variable. Also put it into the search form, using a hidden field.

When the form is submitted, check whether the number in the session is the same as the one coming in from the form. If they are not, don't do the search, as this search has already "expired".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top