Basic PHP form handler object.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Basic PHP form handler class.


$form = new FormHandler();
$form->to = "";
$form->subject = "Contact Form Submission Received!";

OPTIONS (and default values):

testing = false (bool)

If true, won't actually send an email. Use with show_message for testing/debugging

show_message = false (bool)

Great for debugging. Displays all received form data

to (string, array)

Email address(es) which will receive form submissions

subject = "Form Submission Received"

Subject of generated email

cc (string, array)

Email address(es) to CC

bcc (string, array)

Email address(es) to BCC

required (array)

Array of required input names

from_name (string)

Name the generated email will come from

from_email (string)

Email address the generated email will come from

validate_emails = true (bool)

Check whether email addresses submitted through form are valid

filter_spam = false (bool)

Help prevent spam by checking for a $_POST['timer'] value - works well with validatr

html_email = true (bool)

Sends an html email as opposed to a plain text email

include_reload_link = false (bool)

Includes a link to reload page on failed form submission

success_message = "Thanks for contacting us!" (string)

Displayed on successful form submission

spam_error = "There was an error with your attempt to contact us." (string)

Displayed after a suspicious form submission

redirect_url (string)

URL to redirect to after successful form submission


Be sure to include the FormHandler.php file: include('FormHandler.php');

It only makes sense to use FormHandler after a form submission, so wrap it in a conditional:

	$form = new FormHandler();
	// And so on...

See it in action

Developed by Stephen Widom -