On Sunday, April 14, 2002, at 07:56  PM, Jason Caldwell wrote:

> I have a form, when the user presses the submit button, I pass the form 
> vars
> to my PHP checkform.php script -- which checks all the fields to make 
> sure
> the user entered the correct values -- if the user missed something, 
> then
> they are passed to my error page, which lists out the fields they need
> fix -- ideally, i would like them to press their browsers BACK button to
> return to the form, instead of reloading all their session data back 
> into
> the form with a submit button on the error page -- too much data.
>
> So, in Netscape, when a user presses their BACK button all the fields 
> are
> filled in just as they were filled in ... including the password field.
> However, in Internet Explorer, when the user presses their BACK button, 
> all
> fields are good EXCEPT the password fields, which are bank ... so the 
> user
> is forced to reenter their password info -- kinda annoying.
>
> Is there a HEADER or something or an IE fix anyone knows of that will 
> force
> IE not to delete the password info in this manner?

I get around this entire problem by not forcing the user to use their 
"BACK" button if they've made a mistake at all.

The form itself is the return value of a function, called "print_form()" 
or something like that.  I have dozens of these functions in my pages, 
btw.  Anyway, one of the cool things about this is that I can re-use 
this function as many times as I need to create this form.  So if the 
user fails the error-check or the input is invalid, or whatever, I just 
execute the function again and the form is displayed.

How do I get the original values back?  Well, each <input> in HTML has a 
"value" attribute.  That's the default value of the input, in the case 
of text inputs then the value will be echoed in the text box, et 
cetera.  In listbox inputs you can use selected="yes" so that the user's 
choice is selected.  I just put the user's input as the "value" of my 
HTML form inputs.  Here's an extremely simple example of such a function:

function print_simpleform()
{
$simple_form = "<form method=\"post\" action="" . 
$_SERVER['PHP_SELF'] . "\">
<input type=\"text\" value=\"" . 
htmlentities($_POST['userinput']) . "\" />
</form>\n";

return $simple_form;
}


Of course, you can get far more complex and have functions that do this 
but use database info as the default values, et cetera.  Also, you may 
need to "stripslash()" your $_POST data if you have gpc_magic_quotes = 
on.


Erik


----

Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to