I have a classifieds website, and when posting a new classified users fill out a form offcourse. Then they hit the submit button, and a "verify" page appears which displays what they have filled out, and if it looks good, the users hit the "ok" button and the classified is posted.
Here is a short example:
<form action="verify.php" name="main_form" etc
Then from verify.php if the classified looks good, they hit OK, and it is posted.
However, here they have the option of clicking "back" to change something, which is where my problem comes in.
Now, at the bottom of the main_form, I have file-upload tool, which refreshes the page for each upload. This is what is causing the problem. However, it is too late for me to change it to a non-refreshing file-upload now (ajax for instance).
Anyways, the problem is that IF the user have uploaded a file and submits the page, the verify page opens. So from here the back button only displays a "Warning: page has expired" instead of showing the form with the images uploaded.
However, users are able to press F5 (refresh) to refresh the browser and the form will appear once again as it was, but this is no good solution.
How can I fix this?
And how come other browsers don't have this problem, they actually go back and display the full form with the images?
Also, offcourse, if no images are uploaded, the back button works fine in IE.
If you need more input let me know...
BTW; NOT TESTED IN IE8 YET.
see: Chris Shiflett: How to Avoid "Page Has Expired" Warnings:
RecapTo avoid "Page Has Expired" warnings, set session.cache_limiter to private, and make sure that any form using the POST method submits to an intermediate processing page that redirects the user to a different URL.
Just do not use verify.php, but make it all on the same page.
http://en.wikipedia.org/wiki/Post/Redirect/Get
Related
When I go to localhost:PORT/ADMIN.php, I am brought to the login page to sign in as an administrator. As soon as this page loads, it displays:
ERROR: The username field is empty.
ERROR: The password field is empty.
… before I've even clicked the "Log In" button. It also shakes the form. It behaves the same way when I refresh the page.
Is there a way to prevent the form from automatically submitting on first load?
If anyone is experiencing a similar problem, I was able to fix the issue by modifying functions.php. I created a function (that fires on login_init) that checks if there is any post data for the password field. If there isn't, then I created a blank Wordpress error, which has the effect of clearing any other errors.
I have a html form with security image (captcha) with code based on phpformgen, that behaves differently for MS Internet Explorer and Firefox.
When there is a field form error, an error message pops up. To get back to the form to correct it, back button in the browser is clicked.
Now, after back button is clicked:
IE 10 will display cached(already entered) data so that user does not have to retype all of it, and importantly, there is a NEW captcha displayed that user needs to type in. This is what I want to happen, I think.
Firefox 25 will also display already entered fields but it will not change the captcha !
How can I modify html form or associated php code behavior so that Firefox does not cache the captcha image upon clicking browser back button and behave like IE10 ?
In the form tag you can add autofill off,
autofill='false';
That should do it.
I am building a php web app and I am having some trouble with the navigation. It seems the user have to hit back twice to get past one of my apparent traps. . .
Consider this situation. The user wants to upload a file with a description, so he hits upload and gets directed to the upload.php page. He fills out the form and submits the form to uploader.php. Uploader.php redirects him back to upload.php?yay=true.
From here, he needs to hit back twice to get back to the page where he hit the upload button.
Is there a clever way to keep track of which page he originally came from (this case, 2 pages back) or do i need to keep his navigation story in say the session variable?
I could also just redirect to the page from where the user hit the upload button, but this means that the back button will take him to the fileupload.php page instead of the page previously to the one that had the upload button.
Any help appriciated!
Simple after doing upload stuff, justt redirect him to the original page like
// do the upload stuff
header('location:the_page_name.php');//the page where user originaly came from
I have a strange problem with IE. I have a sequence of forms on my website, and there is a built in navigation system to go to the next and previous pages. The pages submit to themselves, and then use Header(Location: ... ) to proceed to the next page.
The problem is that when I use the built in back button (standard tags) to go to the previous page, the input tags get populated with the old values, but when I refresh the page the values are correct. Similarly, when I use the browser back button the values appear correctly.
Sorry if this is a repost, does anyone know how to solve this problem?
Thanks!
I think it's an issue with IE caching the previous pages; if you can amend the server configuration so that it's passing the No-cache request to the browser, it should fix it.
Is there a way to save the form data so that if the submit fails they don't have to retype everything? For some reason, I'm getting an error on my script with Chrome but not with FireFox. It doesn't always happen with Chrome, and it's not exactly the main problem. If they submit and then the page doesn't load, they lose everything they typed when they go back. I've thought of only one thing so far, but it doesn't seem practical. It would be to save the form data to cookies when they press submit.
Is there a better way?
It depends on what you mean by "submit fails." If you mean that there is a server error, and they have to press 'back', it's hard.
However, if you mean fails as in a they-forgot-to-put-an-email kind of fails, here is one solution:
You can grab the previous values from the $POST or wherever and stick them back into the HTML tags. For instance:
<?php
$prevCustEmail = makeItASafeString($_POST['custEmail']);
?>
<input type="text" id="custEmail" name="custEmail" value="<?php echo $prevCustEmail; ?>" />
Edit: For the server thing, the cookie hack may be the best. Here is another hack idea: You could modify your 500 server error page to have a button on it that says "go back to form", which would only show up in the event that this $_POST data was just went. The button would actually be submitting an identical form where every is type=hidden. This data would then get transferred to the previous page and stuffed in as above.
A third hack would be to load the page in an iframe, and have the success page jump out of the iframe. The server error would not do that. Then use Javascript onSubmit to detect that something has gone wrong, or just hope that the user notices nothing happened and clicks "submit" again.