Ironvine Analytics Web Analytics, Data Analysis, Online Marketing, and Search Engine Information.

14Sep/06Off

PHP: Forms with Image Verification & Security Validation

Forms with Image Verification
DOWNLOAD NECESSARY FORMS HERE (ZIP FILE) >

In an effort to make web forms more secure and prevent spam I have developed a PHP based comment form with image verification. It was designed to make it very easy to use, and no need to modify any cgi files! You can have as many form fields as you like.

There are some instructions that you will need to follow.

1. Forms must be labeled as a .php file
2. Place php code at top of filename.php file at line 1
3. Place form code within html in spot where you want the actual form fields to appear.

SPECIAL NOTE: Only one form will work per page.

4. Place “Thank You” code near top of page (preferrably below page title, just above the content on the page)
5. Change the URL
6. Change Subject
7. Update form fields if need be. Make sure all fields are labeled. – If everything is standard you shouldn’t need to change anything.
8. Place the following files at the same level as the form: arial.ttf, background1.jpg, background2.jpg, background3.jpg, background4.jpg, randomimg.php, sesamefrm.inc.php, filename.php (the form itself)

Optional settings:
To have the page redirected, remove the # and change the redirect URL
To have cc emails add to the php code: $cc='thecc@emailhere.com';

Line 1 of filename.php

[PHP]< ?php
# Instructions:
# Save this file as .php
# Include this ?php section at line 1 of the file
# The submit button must be named 'submit'
# The verification textbox name must be named 'txtNumber' and be accompanied by
# Form action must call this page and be set to POST

# To Email Address
$email='to@emailhere.com';

# Subject
$subject='Web Site Comment Form';

# From Name
$sender='From Your Website';

# From Email Address
$sender_email='webadmin@emailhere.com';

# URL (no www.)
$drurl = "primaryurl.com";

# To use a URL redirect after submission remove the below '#'
# $next_url='http://www.ironvine.com/blog';

###########DO NOT CHANGE THIS LINE############
include("sesamefrm.inc.php");
##############################################
?>[/PHP]

Thank You Code

[PHP] if ($errorMessage != '') {
?>
< p align="center">

< ?php
}
?>[/PHP]

Add the Verification
[html]

Verification Code (case sensitive):

[/html]

Filed under: Code Samples Comments Off
Comments (2) Trackbacks (1)
  1. It’s a very good piece of code… I specially enjoyed the part where the image was created… simple a effective…
    Nice job!

  2. Thanks! I hope you find it useful.

    Steve