Dean219 Dean219 - 1 year ago 87
HTML Question

php post dynamic redirect and prevent form resubmit

I am currently having an issue with the back button in my browser and developing a way to hide the resubmit data warning.

After using the POST method to submit data to php I want to redirect to the location /recipe and once there I wish to use the ID submitted from the post method to search the database for the particular ID to display the data :

echo '<div class="text-center"><pre><h4>';
echo '<form action="" method="post"><button type="submit" name="/recipe"';
echo 'value="';echo $id; echo '"class="btn-link">';
echo '</button></form></h4><p/><p/>';
echo '<p/></div>';

The Post event handler looks like this :

//PATH for clicking recipe
if(isset($_POST['/recipe'])) {
} else {


So php delivers this form with data from the database->you click the button and it posts the ID of the database element to /recipe so you can view just that element on the next page. This all works as expected...however when you click the back button it reveals a "resubmit the form" warning. Iv looked around stackoverflow however every solution involved using


Using this type of redirect just meant the page would redirect to a standard page with no ID being posted and no way for my database to search for the content that i had posted. Does anyone know a way to both submit the ID from my form when the button is clicked, and prevent the resubmit warning from even appearing?

Any help would be appreciated, thanks.

Answer Source

You can add ID to redirect URL


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download