$Client_Name = 'Patrick McGuire Recording'; $Client_Subject = '[PMRec] Contact Form'; $Client_Emails = array('patrickamcguire@me.com'); require_once('recaptchalib.php'); define('PublicKey', '6LdRfPcSAAAAALcryldTyhqjIqhfOC6gmuJZY1WB'); define('PrivateKey', '6LdRfPcSAAAAACmsEWMO_51L1A93cJT3FZdwEPq_'); function validate_email ($address) { return (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'. '@'. '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'. '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $address)); } $gooddata = 1; foreach (array('Fname','Femail','Fcomments') as $Fkey) $_POST[$Fkey] = stripslashes($_POST[$Fkey]); if (isset($_POST['fromform'])) { if ( empty($_POST['Fname']) || empty($_POST['Fcomments']) || !validate_email($_POST['Femail']) ) { $gooddata = 0; unset($_POST['fromform']); } if ($gooddata == 1) { $reCaptcha = new ReCaptcha(PrivateKey); $response = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]); if (!($response != null && $response->success)) { $gooddata = 0; unset($_POST['fromform']); $error_message = 'The Not-A-Robot verification failed.'; } } } if (isset($_POST['fromform'])) { $message = "The following online comments were submitted through the $Client_Name web site on "; $message .= date('M d, Y') . ' at ' . date('h:i a'); $message .= '. Name: '.$_POST['Fname'].' Email: ' . $_POST['Femail'] . ' Comments: ' . $_POST['Fcomments'] . "\n"; if ($_POST['Femail'] == 'not provided') $_POST['Femail'] = $Client_Email; // email all recipients foreach ($Client_Emails as $Client_Email) { mail($Client_Email, $Client_Subject, $message, 'From: '.$_POST['Fname'].' <'.$_POST['Femail'].'>'); } header('Location: thankyou.html'); exit; } ?>
|
|||||||||||