Here's the code:
<?php
//error_reporting(E_ALL);
//ini_set("display_errors", 1);
require_once("includes/form.class.inc2.php");
$form = new Form;
// If form is submitted, check that form fields for have valid
if ((isset($_POST["Submit"]) || isset($_POST["Submit_x"])) && $_POST["Submit"] == "Submit") {
// Take Variables from Form and create PHP variables
extract($_POST);
// Validate Form Fields
//$form->isValidName("Name", "Full Name can only contain letters, spaces, periods, dashes, commas, and single quote.");
$form->isValidName("Name", "Name can only contain letters, spaces, periods, dash, single quote, comma and must start with a letter and must end with a letter or period.");
$form->isValidEmail("Email", "Invalid email format. Please enter format as username@server.com.");
$form->isValidURL("Website", "Please enter website format as http://www.website.com or www.website.com");
$form->isEmpty("Description", "Please enter a description");
if (!$form->isEmpty("City", "")) {
$form->isValidCity("City", "City can only consist of letters and spaces.");
}
if (!$form->isEmpty("State", "")) {
$form->isValidState("State", "State can only consist of letters and spaces.");
}
if (!$form->isEmpty("PostalCode", "")) {
$form->isValidPostalCode("PostalCode", "Zip/Postal Code can only consist of numbers, letters, spaces, and dashes.");
}
if (!$form->isEmpty("Phone", "")) {
$form->isValidPhone("Phone", "Please enter phone format as 999-999-9999.");
}
if (!$form->isEmpty("Fax", "")) {
$form->isValidPhone("Fax", "Please enter phone format as 999-999-9999.");
}
if ($TradeLink == "yes") {
$form->isValidURL("WebsitePage", "Please enter website page format as http://www.website.com or www.website.com.");
$form->isEmpty("WhyLink", "Please enter a why would you like to have a link from E-Z Up direct.");
}
}
else {
// Set Trade to default to yes when form is first displayed
$TradeLink = "yes";
require_once("includes/server.class.inc.php");
$server = new Server;
}
if ((isset($_POST["Submit"]) || isset($_POST["Submit_x"])) && !count($form->error)) {
require_once("includes/email.class.inc.php");
// EZUP Direct Email
$contactEmail = new Email;
$contactEmail->from = $Email;
$contactEmail->fromName = $Name;
// Set EZUP Email Addresses
//$contactEmail->to = "chris@yourhost.com";
$contactEmail->to = "scott@yourhost.com";
$contactEmail->toName = "E-ZUP Direct";
$contactEmail->subject = "E-ZUP Direct.com Link Request";
// Setup Email Message
$contactEmail->message = "A request has been made for a link to ezupdirect.com.\n\n";
$contactEmail->printFormVariables($_POST);
$contactEmail->message .= "----------------------------------------------\n";
$contactEmail->message .= "Remote Address: " . $RemoteAddress . "\n";
$contactEmail->message .= "Remote Port: " . $RemotePort . "\n";
$contactEmail->message .= "Request Method: " . $RequestMethod . "\n";
$contactEmail->message .= "HTTP User Agent: " . $HTTPUserAgent . "\n";
$contactEmail->sendTextEmail();
// Customer Email
$customerEmail = new Email;
$customerEmail->from = "info1@ezupdirect.com";
$customerEmail->fromName = "EZUP Direct";
// Setup CustomerEmail
$customerEmail->to = $Email;
$customerEmail->toName = $Name;
$customerEmail->subject = "EZUP Direct Link";
$customerEmail->message = "Dear " . $customerEmail->toName . ",\n\n";
$customerEmail->message .= "Thank you for your request to put a link on our site, www.ezupdirect.com.\n\n";
$customerEmail->message .= "If your inquiry requires a response, we will be in touch with you soon.\n\n";
$customerEmail->message .= "Sincerely,\n\n";
$customerEmail->message .= "EZUP Direct\n";
$customerEmail->sendTextEmail();
require_once("includes/mysql.class.inc2.php");
$db = new MySQL;
// Open Database Connection and Database
if ($db->openDataBaseConnection("localhost", "user", "password", "p")) {
if ($db->selectDatabase("database")) {
$db->isValidConnection = true;
}
else {
$errorMessage = "Unable to open database and store your information. Please contact Tech Support.";
$db->isValidConnection = false;
}
}
else {
$errorMessage = "Unable to open database connection and store your information. Please contact Tech Support.";
$db->isValidConnection = false;
}
if ($db->isValidConnection) {
$db->sqlStatement = "INSERT INTO ezup_links ";
$db->createSetStatement("Submit,MAX_FILE_SIZE", $_POST);
if (!$db->ExecuteSQLStatement()) {
$errorMessage = "Unable store your information in database. Please contact Tech Support.";
}
}
// Goto Thank You Page
$location = "ezup-linkback.php";
if (isset($errorMessage)) {
$location .= "?ErrorMessage=" . urlencode($errorMessage);
}
//echo $location;
header("location:" . $location);
}
?>