SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2005
    0 Post(s)
    0 Thread(s)

    Best PHP data validation method for HTML forms?

    Hello everybody!

    It's really tough for me to figure out what is the best method for validating form data that is going to later be INSERTED into mySQL database once submitted.

    How I have my form set up is that once it is posted, it goes to a handler page, that takes the $_POST['formvalue'] and inserts it into the database.

    But once I'm on the handler page, if I validate the values there and they show to be not valid, if I send the user back to the form page, it does not keep the $_POST values to put back in the appropriate HTML form fields so that they are not blank and the user has to fill in the form all over again.

    On the other hand, if I have the form post back to itself, once I validate the $_POST values and if they are valid and I send the user to the handler page to update the database with the SQL statements, the $_POST values will be gone.

    What I'm basically asking is, once the form is submitted the $_POST values only go to the page submitted to when I need them to be able to go to the next page in either of the scenarios I described. Any comments or suggestions are much appreciated.

  2. #2
    SitePoint Evangelist catweasel's Avatar
    Join Date
    Apr 2007
    Goldfields, VIC, Australia
    0 Post(s)
    0 Thread(s)
    you could have it all in one file

    form validation

    database insert/update

    html form.


Posting Permissions

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