Contact Menu

Auto Mailer Form with Validation and reCAPTCHA

Screen Shot 2013-01-16 at 4.19.03 PMI was recently searching for a form template that uses Twitter’s Bootstrap framework. PFBC, the PHP Form Builder Class, was recently refactored with Bootstrap, and it also supports validation and reCAPTCHA. PFBC does not include a form handler, but it does take the difficult and redundant work out of creating self-validating forms.

Adding an auto-mailer to PFBC is very simple, however. You just need a simple PHP if/else and all is well.

If you have read this far, you should go ahead and download PFBC version 3 (with Bootstrap). You’ll want to install it on a dev server and read the documentation, which is on the example pages. Installation: put the downloaded folder in a public_html space that’s running PHP 5+.

Note that there are different packages for PHP 5.3, so get the correct flavor of version 3. This example works with PHP 5.3.

I have created an example form that includes most of the different types of inputs, all you need do is create a file in the same folder as the package’s main index.php. I’ve heavily commented the code, so you should be able to easily understand it.

If you want to implement a form on a site that does not include Twitter Bootstrap, you may find the bootstrap.css conflicts with many of your site’s styling.

In that case, you can go to Bootstrap’s Customize and Download page, and choose only the css, js and components you need:

Scaffolding
none

Base CSS
Forms, Buttons

Components
Button groups, Alerts

JS Components
Collapse

Miscellaneous
Close icon

Utilities
Component animations

Responsive
none

2 Responses to Auto Mailer Form with Validation and reCAPTCHA

  1. Steve April 3, 2013 at 11:44 am #

    I couldn’t get this to work as written. The browser report tahat a redirect can’t be completed. Basicaly it was stuck in a loop reloading the page. By moving the IsValid method to the end of the form so the form loads first I could get it to work.

    • Chris Gilligan May 21, 2013 at 9:47 am #

      What version of PHP are you running? This example works with PHP 5.3+

Leave a Reply