From: Chris <dmagick@xxxxxxxxx>
That has to be your code re-setting the session variables or something. PHP
won't do this automatically for you.
Well I suppose it's "or something". Try this code. Name it test.php:
<?php
//session_start();
$notice = "";
if($_SERVER['REQUEST_METHOD'] == "POST"){
if($_POST['f2'] == ""){
$notice = "*Required";
}
}
?>
<html>
<head>
<title>Test</title>
</head>
<body>
<form action="test.php" method="post">
Field1: <input name="f1" type="text"><br />
Field2: <input name="f2" type="text"><?php echo $notice; ?><br />
<input type="submit" value="Submit">
</form>
</body>
</html>
A) With session_start commented out as above:
A1. Go to the test.php page in your browser (using the GET method) by typing
in the URL.
A2. Enter something in Field1. (Do not enter anything in Field2.)
A3. Press Submit.
Next to Field2 should have text, "*Required".
A4. Press your Back button in your browser.
Field1 retains its contents.
B) With session_start uncommented so as to be called (Edit test.php to now
call session_start):
B1. Follow steps A1 to A4 above.
Field1 has lost its contents!
Where did my code reset a session variable?
C) If I add many line break br tags immediately before the submit input tag,
so that you are required to scroll down to see the Submit button, after step
A4 you will notice that the page reloads when using sessions, but seems to
be cached by the browser when not using sessions.
If this is the case, can I instruct PHP to let the browser use its cache
while still using PHP sessions (i.e. session_start)?
This behavior occurs in (standard?) FF 2.0.0.4, and IE 7.
It did not occur on an obscure FF which also reports version 2.0.0.4, named
"FrontMotion Firefox Community Edition". That's also why I thought I could
dismiss it as user browser settings.
_________________________________________________________________
http://newlivehotmail.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php