Logo Background RSS

Easier form validation with PHP

  • Written by vinuvinu No Comments Comments
    Last Updated: April 20th, 2006

    Here’s a class from Simon Willison which allows you to create an easy form generation and validation system for PHP.
    Let’s talk about form validation. Here’s what I would class as the ideal validation system for a form in a web application:

    1. The form is displayed; you fill it in.
    2. You submit the form to the server.
    3. If you missed something out or provided invalid input, the form is redisplayed pre-filled with the valid data you already entered.
    4. The redisplayed form tells you what you got wrong. It also flags the fields that were incorrect.
    5. Loop until you fill the form in correctly.

    Writing this once in PHP is trivial, but takes quite a bit of very dull code. Writing this for more than one form quickly becomes a tedious nightmare of duplicating and slightly editing code, which is why so few forms bother.

    Link: Simon Willison: Easier form validation with PHP

    Bookmark and share:
    • del.icio.us
    • Digg
    • StumbleUpon
    • BlinkList
    • blogmarks
    • Furl
    • Slashdot
    • Spurl
    • Technorati
    • YahooMyWeb
    • description
    • Facebook
    • Google
    • Live
    • Ma.gnolia
    • NewsVine
    • Reddit
    • TwitThis

Advertisement

Leave a Comment