php


Document Expires After Redirect If Form Did Not Validate


Looking for some advice on this problem. I happened to run into using the php framework Yii, but seems more a universal issue with web forms/my lack of understanding this concept.
Issue: When pressing the back button on the browser, user gets "Document Expired" only if the form had a validation error. If there was no validation error before it was submitted, there is no "Document Expired" problem (because of the redirect).
Take this simple generic example of a controller:
public function actionSomething() {
$model=new ExampleClass;
if(isset($_POST['ExampleClass'])) {
$model->attributes=$_POST['ExampleClass'];
if($model->validate()) {
$this->redirect(Yii::app()->createUrl('some/where'));
}
}
$this->render('_form',array(
'model'=>$model
));
}
So when validation fails, the form is sitting there with $_POST data. Then, data is submitted again, validation passes and the redirect happens. Next, when the back button is pressed on the browser, it runs into the form in the state prior to passing validation and I get the "Document Expired" problem.
How can I prevent this?
I'm not totally sure how far or what you're willing to try - I might suggest using sessions to store variables. Doing this will allow you to recall the values of the variables during a page refresh.
http://us2.php.net/manual/en/session.examples.basic.php
Here's a better link for a usage demo:
http://www.w3schools.com/php/php_sessions.asp

Related Links

Display posts on homepage - Custom PHP CMS
How to get specific substring digit from string using php? [duplicate]
How to get featured image from post
How to catch 401 response in Laravel/Lumen?
Remove the top level array and merge sub array into one
PHP GET Variable [duplicate]
JQuery AJAX is encoding API Token for Laravel Application, results in 401 Unauthorized
ShareThis webservice on Drupal 7 site has stopped working (images not appearing)
Wecoomerce custom query to filter products loop
Unable to get PhpMailer working with Office 365
How to link php mvc page through href
database connected but not responding as expected when queried
Concat comma separated firstname and lastname using mysql
Using Instagram api without authentication
Android Studio simple notification using json/php
Mysql add 1 day to timestamp

Categories

HOME
rust
artificial-intelligence
odata
position
angular-meteor
phpseclib
jpa-criteria
fireloop
chromecast
stimulsoft
heap-dump
pinterest
pygobject
cocos2d-android
varnish-vcl
tfsbuild
codefluent
liferay-6.2
android-cardview
ninject
envoy
guice
series
universal
xmlunit
spring-rabbitmq
rails-postgresql
assertions
installanywhere
llvm-ir
data-uri
oauth2-playground
coverage.py
haar-classifier
sendinput
apache-toree
aws-kinesis-firehose
django-static-precompiler
photoswipe
openstack-glance
winston
sesame
nrf51
ndk-build
between
static-methods
strpos
jemdoc
preferenceactivity
android-expansion-files
diawi
servicestack-bsd
asp.net-web-api-helppages
screen-orientation
supercomputers
angular-amd
dbmigrate
deque
tidyr
nanomsg
jquery-mobile-flipswitch
category-theory
treeline
bittorrent-sync
tabletools
oxygene
jchartfx
jomsocial
windows-taskbar
lsa
void-pointers
xs
cyrillic
spark-view-engine
xcode4.5
coordinate
cakeyframeanimation
jzmq
kernel32
hungarian-notation
cassini
resharper-5.0
watchpoint
remote-working

Resources

Encrypt Message