PHP error on form submit but keep filled in forms

Discussion in 'Programming' started by madskillsmonk, Nov 22, 2012.

  1. #1
    So i have a registration form on my website (for example). What i want is that when i do all the verification on the backend, if i find the user made a mistake on one (or more) of the fields, i will send him back to that registration page with a header. How can i keep it so that the fields that didn't have an error can be sent back to the form i will just output them as the value of the text input. Understand what im saying? :p
    Thanks
     
    madskillsmonk, Nov 22, 2012 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    Either of two ways:

    1) Use AJAX to verify the form. If it fails, put a notice on the page and put the cursor in the first element with an error. (Use onKeyPress and OnMouseMove on the document to kill the message.)

    2) On the PHP page, if the form is being submitted (or unconditionally if you use a separate PHP file), capture the data from the form. When the verification fails, fill in the values from the saved data, put up the failure message, put the cursor in the first failure element and send the page.
     
    Rukbat, Nov 22, 2012 IP