Request for help: HTML forms blank after pressing browser "Back" button

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I would appreciate any help with the following problem.

I have several different htm pages with (simalar) forms that are
processed by the same
PHP script.  If there is data missing on the form, the script displays
an error page (using the header() function) and informs the user to
the browser's "Back" button.  The problem is that when the user goes
to the form's htm page, all the fields are blank.  I would like all
the fields to
contain the data the user previously entered,  so that only the
missing data
needs to be entered.

This happens sometimes but not always.

The pseudocode is something like this:

MyWebForm.htm (contains the html form) and links to:
  <form name="reservation" action="ProcessWebForm.php" method="POST">
-->  Inside ProcessWebForm.php:
  // Gets the information from the forms
  if ($_POST['firstname']) {
      $required_first = $_POST['firstname'];
  else {
       header("Location: nofirstname.html");
--> Inside nofirstname.html:
<head><title>Missing Reservation Information, NAME</title></head>
Sorry, you have omitted your First Name.  Please click your computer's
button to return to the reservation form and enter your first

Re: Request for help: HTML forms blank after pressing browser "Back"button


On 08/04/2004 12:02 AM, Ray Torres wrote:
Quoted text here. Click to load it

Nothing stops you from generating, validating and processing the forms
in the same page. This way you do not need any redirection.

You may want to take a look at this forms generation and validation
class that lets you do what you want in the same page. You can even
define the form presentation from templates and have the class load any
submitted values and validate them either on the client side and server

If there any invalid values, the class can present the form again
with the previously submitted values using the same script and form


Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP /

PHP Reviews - Reviews of PHP books and other products /

Metastorage - Data object relational mapping layer generator

Re: Request for help: HTML forms blank after pressing browser "Back" button

Lemos contained the following:

Quoted text here. Click to load it

Eventually maybe.  For now he's better off learning how to code it
himself instead of using a black box which he does not understand.

Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs /

Re: Request for help: HTML forms blank after pressing browser "Back" button

Quoted text here. Click to load it

Change your setup, let the "page" that validates return the form with
the valid entries already filled in together with the reason the user
see the form again (the errors).

So essentially combine the form generation and error handling in 1
"page". This doesn't rely on any clientside magic so it works perfectly
all of the time.


  Daniel Tryba

Site Timeline