include_once 'includes2/functions/validations.php'; include_once 'includes2/configure.php'; include_once 'includes2/functions/general.php'; include_once 'includes2/classes/email.php'; include_once 'includes2/functions/substitute.php'; $actionverb = array_key_exists('actionverb', $_POST) ? $_POST['actionverb'] : null; $errorfound = false; $message = null; $errors = array(); if ($actionverb == 'submit') { // Validate form if (!array_key_exists('first', $_POST) || !$_POST['first']) $errors['first'] = 'first name required'; if (!array_key_exists('last', $_POST) || !$_POST['last']) $errors['last'] = 'last name required'; if (!array_key_exists('phone', $_POST) || !$_POST['phone']) $errors['phone'] = 'phone required'; if (!array_key_exists('email', $_POST) || !$_POST['email']) $errors['email'] = 'email required'; if (array_key_exists('email', $_POST) && $_POST['email']) { if (!validate_email($_POST['email'])) { $errors['email'] = 'invalid email address'; } } if (sizeof($errors) > 0) $errorfound = true; if (!$errorfound) { $params = array('name' => "{$_POST['first']} {$_POST['last']}", 'email' => $_POST['email'], 'phone' => $_POST['phone'], 'comment' => $_POST['comment']); $adminstatement = file_get_contents('Messages2/adminMessage.html'); $adminstatement = substitute($adminstatement, $params); $msg = new Email('charlie@chartmarketing.com', 'New MakeItMyBook.com Contact Request'); $msg->Bcc = 'ctraffas@chartmarketing.com'; $msg->TextOnly = false; $msg->Content = $adminstatement; if (!$SendSuccess = $msg->Send()) { $errorfound = true; $message = "Unable to send your request. Please retry."; } $userstatement = file_get_contents('Messages2/userMessage.html'); $userstatement = substitute($userstatement, $params); $msg = new Email($_POST['email'], 'charlie@chartmarketing.com', 'MakeItMyBook.com'); $msg->Bcc = 'ctraffas@chartmarketing.com'; $msg->TextOnly = false; $msg->Content = $userstatement; if (!$SendSuccess = $msg->Send()) { $errorfound = true; $message = "Unable to send your request. Please retry."; } } } ?>