www.webdeveloper.com
Results 1 to 2 of 2

Thread: Form refreshes when redirected from header

  1. #1
    Join Date
    Jun 2006
    Location
    England, UK
    Posts
    71

    Form refreshes when redirected from header

    Hello all,

    I have a registration form. The form submits the information to the script (on another page) using POST method. The script checks the various fields to ensure it's being given the required information. If the information is wrong or incomplete it will send the user back to the registration page with some information in the URL to highlight the fields that were wrong.

    The problem I face is that all the fields reset and become empty, forcing the user to input all the information again.

    Is there a way to stop the fields refreshing?
    n00b like no other

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,220
    You'll probably want to use session variables with the form data, then in each form element you'll need to check if there is a corresponding $_SESSION value for it, and if so, assign it to that form element's value (or make it the selected option in a select element). This points to one advantage of having a form page submit to itself, so that you can simply get the data straight from the $_POST array if you need to redisplay the form, using some branching logic in the script to determine if you are initially displaying the form, redisplaying it because of input errors, or going ahead and processing it and then displaying the results (possibly using a redirect at that point so that the browser refresh will not re-submit the form).
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles