Well, I'm nt sure if this is my php, or my html. I only assume php since that's the more confusing part. I have a form, and when you click submit, it is handled by a seperate php file. On my other similar forms, when you are forwarded back, or if you click the back button, all the form data is still there. This one doesn't do that. Any idea why? I'm attaching a zip file with the 2 files in it.Are you printing no-cache headers?
header("Cache-control: no-cache, must-revalidate");
header("Pragma: no-cache, must-revalidate");
header("Expires: -1");or are you using sessions?
but I think Jere hit it on teh head.Sorry to ask a question, and then ignore the answers...I got too busy to get back to here for a while.
Well, I don't see anywhere where I set any headers like that. I AM using sessions, but I'm using them on other pages that work also. Why might sessions affect it?
EDIT: Ps...the code for both pages is attached to the first message. You can see the session start at the top, but no headers like the ones you asked about.because when using sessions it makes the browser reload the page on a form.Hmmm...is there any way around that? Some of these forms are in an area that is for employees only, so you are required to log in first. I'm using the sessions to verify that user_logged_in is set. But for the forms, if they enter a whole bunch of data, and leave off one little thing, I don't want them to have to re-enter everything.those headers and/or you can add
session_cache_limiter("private"); before session_start()
or
session_cache_limiter("nocache");
<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.session-cache-limiter.php">http://www.php.net/manual/en/function.s ... imiter.php</a><!-- m -->
but I have not run into those problems myself and I dont' use any of those headers. the only thing I do it have a variable that loads in the textbox fomr the db, or forma session. hmmm, I am gonna have to play around with that idea.I never force my visitors to use the back button, if something goes wrong with the form, they see the same form again, with their values filled in, and then the error message.I added<?php session_cache_limiter("private") ?>right before the session start on the page that contains the form. It seems to work.
ThanksOk, I've used this to make the data stay in the form:
<?php session_cache_limiter("private") ?>
BUT, is there a way to make the cache expire after a couple minutes?
The problem is that people have to be logged in to see the page, but if you aren't logged in, you will still see it since it is cached. You can't do anything, because if you submit the form it'll tell you you need to log in, but I'd rather let people know that they need to login before they go through the hassle of filling out the form. The data really only needs to be cached for like 1-2 minutes after the submit button is hit. Can you do this?
EDIT: I tried session_cache_expire(1); by the way, and it doesn't seem to work.then you have to send the headers, but not sure if they will work together
@header("Expires: Tue, 26 Jul 1983 05:00:00 GMT");
// always modified
@header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-control: no-cache, must-revalidate");
header("Pragma: no-cache, must-revalidate");
header("Expires: -1");or are you using sessions?
but I think Jere hit it on teh head.Sorry to ask a question, and then ignore the answers...I got too busy to get back to here for a while.
Well, I don't see anywhere where I set any headers like that. I AM using sessions, but I'm using them on other pages that work also. Why might sessions affect it?
EDIT: Ps...the code for both pages is attached to the first message. You can see the session start at the top, but no headers like the ones you asked about.because when using sessions it makes the browser reload the page on a form.Hmmm...is there any way around that? Some of these forms are in an area that is for employees only, so you are required to log in first. I'm using the sessions to verify that user_logged_in is set. But for the forms, if they enter a whole bunch of data, and leave off one little thing, I don't want them to have to re-enter everything.those headers and/or you can add
session_cache_limiter("private"); before session_start()
or
session_cache_limiter("nocache");
<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.session-cache-limiter.php">http://www.php.net/manual/en/function.s ... imiter.php</a><!-- m -->
but I have not run into those problems myself and I dont' use any of those headers. the only thing I do it have a variable that loads in the textbox fomr the db, or forma session. hmmm, I am gonna have to play around with that idea.I never force my visitors to use the back button, if something goes wrong with the form, they see the same form again, with their values filled in, and then the error message.I added<?php session_cache_limiter("private") ?>right before the session start on the page that contains the form. It seems to work.
ThanksOk, I've used this to make the data stay in the form:
<?php session_cache_limiter("private") ?>
BUT, is there a way to make the cache expire after a couple minutes?
The problem is that people have to be logged in to see the page, but if you aren't logged in, you will still see it since it is cached. You can't do anything, because if you submit the form it'll tell you you need to log in, but I'd rather let people know that they need to login before they go through the hassle of filling out the form. The data really only needs to be cached for like 1-2 minutes after the submit button is hit. Can you do this?
EDIT: I tried session_cache_expire(1); by the way, and it doesn't seem to work.then you have to send the headers, but not sure if they will work together
@header("Expires: Tue, 26 Jul 1983 05:00:00 GMT");
// always modified
@header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");