eire web design home page contact eire-web design eire web design and development site map
stepping on in business
• PHP Form creation and basic validation

PHP Form creation and basic validation



As a developer and web designer,  the most frustrating part I have found  is when working with forms.
Long time ago (about 2 years now) I start putting togheter few PHP function trying to make my life a lot easier, but never got the time to finish it off.

Finally I have put everything on the side and got cracking on this due to a new project that involves the making a few very long forms.

The thought of writing all the html code (tables or DIVs) and validate them made me go back to this little project and decided to give it more thoughts.

This is the first release of the PHP code for this project so, if you would like to give it a bash and make use of it please do so…

A sample can be found here: SAMPLE PHP FORM

Some of the features:

  • Choice of using TABLE or DIVs for layout
  • You can create more than one form on the same page making sure the right one is validated on submission
  • Basic form validation
  • Option to make the field required or not
  • Show ERROR message  beside the required field – standard
  • Option to set the ERROR message text – set to REQUIRED in the sample form
  • Show ERROR message at the top of the form as well - optional
  • Cuts form creation time in more than half
  • Automatically sets the values of the field after posting the form
  • Option to add javascript code to the field (e.g. for use with ajax, etc)
  • and much more…

If you find any errors and anything that could help improve the functionality of this project, please leave a comment and I’ll make sure it gets done ASAP.

Share and Enjoy:
  • Digg
  • del.icio.us
  • blogmarks
  • Reddit
  • StumbleUpon
  • Technorati
  • Blogosphere News
  • Facebook
  • Google Bookmarks
  • Mixx
  • MySpace
  • Yahoo! Bookmarks
  • Yahoo! Buzz
  • LinkedIn

Tags: ,

This entry was posted on Saturday, January 2nd, 2010 at 3:41 pm and is filed under PHP. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading ... Loading ...


  • 2 Responses to “PHP Form creation and basic validation”

paul Says:
February 13th, 2010 at 10:45 pm

Hi Louie,
interesting idea, some ideas for maybe your next version …

* a security check to make sure that the submission URL is from the same domain
* CAPTCHA support
* field length limiting
* text box effects (character counter for limited forums / textarea resize to always have a blank line)
* ability to email form results, or store in a DB

Paul

Louie @ Eire Web Design Says:
February 13th, 2010 at 11:57 pm

Hi Paul,

Thanks for dropping around and thanks for the ideas.

* security – can be easily implemented
* CAPTCHA – will be added to the next update (already done but not finished)
* characteres counter – there is an option to add javascript to the end of the field (e.g. onfocus, etc) which can call a JS function
* email – that’s done already in my sample as for DB has to be done manually by the user as there is no way to know the DB name, table name and fields….

ANyway, once againg thanks for the good points.

  • Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Links...

Chicklets...
  • http://www.eire-webdesign.ie/blog/feed/
    http://www.eire-webdesign.ie/blog/feed/
    Google Reader or Homepage
    Add to My Yahoo!
    Subscribe with Bloglines
    Subscribe in NewsGator Online
    add to msn
    Add to My AOL
    Add to Technorati Favorites!
    pageflakes
    windows live