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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ray Torres

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

    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
    press
    the browser's "Back" button. The problem is that when the user goes
    back
    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:
    ProcessWebForm. php:
    <form name="reservati on" action="Process WebForm.php" method="POST">



    --> Inside ProcessWebForm. php:
    //-------------------------------------
    // Gets the information from the forms

    if ($_POST['firstname']) {
    $required_first = $_POST['firstname'];
    }
    else {
    header("Locatio n: nofirstname.htm l");
    exit;
    //--------------------------------------



    --> Inside nofirstname.htm l:
    <html>
    <head><title>Mi ssing Reservation Information, NAME</title></head>
    <body>
    Sorry, you have omitted your First Name. Please click your computer's
    Back
    button to return to the reservation form and enter your first
    name.</font></p>
    </body>
    </html>
  • Daniel Tryba

    #2
    Re: Request for help: HTML forms blank after pressing browser &quot;Back&quot ; button

    Ray Torres <raytorres@gmai l.com> wrote:[color=blue]
    > 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 press the browser's "Back" button. The
    > problem is that when the user goes back 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.[/color]

    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

    Comment

    • Manuel Lemos

      #3
      Re: Request for help: HTML forms blank after pressing browser &quot;Back&quot ;button

      Hello,

      On 08/04/2004 12:02 AM, Ray Torres wrote:[color=blue]
      > 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
      > press
      > the browser's "Back" button. The problem is that when the user goes
      > back
      > 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.[/color]

      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
      side.

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




      --

      Regards,
      Manuel Lemos

      PHP Classes - Free ready to use OOP components written in PHP
      Free PHP Classes and Objects 2025 Versions with PHP Example Scripts, PHP Tutorials, Download PHP Scripts, PHP articles, Remote PHP Jobs, Hire PHP Developers, PHP Book Reviews, PHP Language OOP Materials


      PHP Reviews - Reviews of PHP books and other products


      Metastorage - Data object relational mapping layer generator

      Comment

      • Geoff Berrow

        #4
        Re: Request for help: HTML forms blank after pressing browser &quot;Back&quot ; button

        I noticed that Message-ID: <2nb52nFudrelU1 @uni-berlin.de> from Manuel
        Lemos contained the following:
        [color=blue]
        >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.[/color]

        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 http://www.ckdog.co.uk/rfdmaker/

        Comment

        Working...