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.