I have the following code, which is just a simple HTML form (POST method). I have tried to get the "Confirm form resubmission" message of the browser, by sending the form, hitting browser's back button and then the forward button, and to my surprise, the page displays perfectly, with no errors. However, in other pages I get the message, which is expected and this is one of the reasons the PRG method (POST/Redirect/Get) was invented. Why cannot I reproduce the error with the code below?

<!DOCTYPE html>
            <meta charset="UTF-8">
                <title>PRG Form test</title>
            <form name="form" id="form" action="prg.php" method="POST">
                <label for="name">Name: </label><input type="text" name="name" id="name" value="<?php if(isset($_POST['name'])) print addslashes($_POST["name"]); ?>" />
                <input type="submit" name="send" id="send" value="Send" />

In other pages with much more HTML (and PHP) code, invariable I get, in all tested browsers, the following message (which is the error I would expect, from my experience and reading about the resubmit problem and the PRG solution. When trying to implementing it, I find out that with a simple form I cannot reproduce it!)

Confirm form resubmission

This webpage requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed. Press Reload to resend that data and display this page. Reload this webpage.

Press the reload button to resubmit the data needed to load the page.

After some additional research, the message only appears in friendly-URL pages, which are re-directed to index.php. The .htaccess conf which enables this behaviour is listed here (the part that controls it):

RewriteCond %{THE_REQUEST} ^GET\s.+\.php [NC]
RewriteRule ^(.+)\.php$ /$1 [NE,R=301,L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
  • Please add your page's cache headers to your question. – Stephen Ostermiller Jul 5 '16 at 10:46
  • There are no meta cache set in HTML nor in PHP. I have reproduced the problem, and it only affects friendly-URL pages. If I use the *.php file directly, it works without error. The error is delivered when using the friendly-URL format. So it may be due to this .htaccess config, which delivers all aliases to index.php (Updated in question) – Cesar Jul 5 '16 at 11:20

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.