Mobile app version of vmapp.org
Login or Join
BetL925

: Why cannot I reproduce Confirm form resubmission scenario? I have the following code, which is just a simple HTML form (POST method). I have tried to get the "Confirm form resubmission" message

@BetL925

Posted in: #Browsers #Html #Php #Post

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>
<html>
<head>
<meta charset="UTF-8">
<title>PRG Form test</title>
</head>
<body>
<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" />
</form>
</body>
</html>


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} ^GETs.+.php [NC]
RewriteRule ^(.+).php$ / [NE,R=301,L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/.php -f
RewriteRule ^(.*?)/?$ .php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

10% popularity Vote Up Vote Down


Login to follow query

More posts by @BetL925

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme