PHP Web Form Snippets and Tools

When creating php web forms, there are a few things I always like to have in reach. Don’t expect anything groundbreaking in this list of tools and code snippets. I will also try to update the list as time goes on.

Capture the Visitor’s IP Address

This is always handy, especially when a spam bot manages to get past your defenses. You can ban them from your server.

$ip   = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];

Add a Time Stamp

This helps tremendously to know when someone signed up for your service, in your own time zone. Great for database entries.

date_default_timezone_set('America/Boise'); // Choose your own timezone here
$time_stamp = date('Y-m-d H:i:s');

PHP Mailer for Sending eMail

I like to use PHP Mailer for sending mail. Sure, WordPress or any other CMS could do it as well. Even still, it’s easy to deploy on any site, independent from your CMS. If you don’t have a CMS or plan on changing your CMS at some point in the future, this is a great way to go.

Find PHP Mailer on Google Code

Simple AJAX Form Submissions

I like to use the jQuery Form Plugin from @malsup. It basically makes AJAX form submissions dead simple.

Related Articles

Published by

Tim Bunch

Tim Bunch is a Web Developer from Boise, Idaho. As a web standards fanatic, he passionately pursues best practices. He also actively engages people on a wide range of topics in a variety of social media networks. Tim is also an avid Wordpress developer, music maker, coffee drinker, and child raiser. @timbunch

Leave a Reply

Your email address will not be published. Required fields are marked *