k0dex
04 Nov 2010, 12:54 PM
Hi There,
Hope you can help! Tried so many combinations here, just wondering where to put the recaptcha code that's here http://code.google.com/apis/recaptcha/docs/php.html ?
Any help would be much appreciated as it's been troubling me for couple of days!
<?php
// check if the newsletter form has been submitted
if ($_POST["Button"] == "EMail") {
$emailNotice = "";
if (empty($_POST["name"])) $emailNotice .= "Please enter your name<br>";
if (!eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $_POST["email"])) $emailNotice .= "Please enter a valid email address<br>";
if (empty($_POST["telephone"])) $emailNotice .= "Please enter your telephone number<br>";
if (empty($_POST["enquiry"])) $emailNotice .= "Please select the nature of your enquiry<br>";
if (empty($_POST["enquiry2"])) $emailNotice .= "Please describe how we can help you<br>";
if (empty($_POST["howfound"])) $emailNotice .= "Please select how you found our website<br>";
if (empty($emailNotice)) {
define("EMAILCONTACT", "claire@aditrainer.com");
// construct the email
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$headers .= 'To: ' . EMAILCONTACT . "\n";
$headers .= 'From: ' . EMAILCONTACT . "\n";
$subject = "IMPORTANT - Contact request from Active website";
$recipient = EMAILCONTACT;
$emailcontent = implode("", file("email/contactrequest.htm"));
$emailcontent = str_replace("|||NAME|||", htmlspecialchars($_POST["name"]), $emailcontent);
$emailcontent = str_replace("|||EMAIL|||", htmlspecialchars($_POST["email"]), $emailcontent);
$emailcontent = str_replace("|||COMPANY|||", htmlspecialchars($_POST["company"]), $emailcontent);
$emailcontent = str_replace("|||ADDRESS|||", str_replace("\n", "<br>", htmlspecialchars($_POST["address"])), $emailcontent);
$emailcontent = str_replace("|||POSTCODE|||", htmlspecialchars($_POST["postcode"]), $emailcontent);
$emailcontent = str_replace("|||TELEPHONE|||", htmlspecialchars($_POST["telephone"]), $emailcontent);
$emailcontent = str_replace("|||TIME|||", htmlspecialchars($_POST["time"]), $emailcontent);
$emailcontent = str_replace("|||ENQUIRY|||", htmlspecialchars($_POST["enquiry"]), $emailcontent);
$emailcontent = str_replace("|||ENQUIRY2|||", str_replace("\n", "<br>", htmlspecialchars($_POST["enquiry2"])), $emailcontent);
$emailcontent = str_replace("|||HOWFOUND|||", htmlspecialchars($_POST["howfound"]), $emailcontent);
// send the email
mail($recipient, $subject, $emailcontent, $headers);
$sThankyou = "thank you";
}
}
?>
<h1>Contact Us</h1>
<?php if ($sThankyou != "thank you") { ?>
<p class="strong">For information on any of our services, or to make a course booking, please complete the contact form below and we will contact you at a time to suit.</p>
<p>* required fields</p>
<?php if ($emailNotice) { ?>
<p><strong><?php echo $emailNotice;?></strong></p>
<?php } ?>
<form class="form" action="contact.php" method="post">
<input type="hidden" name="Button" value="EMail">
<fieldset>
<legend></legend>
<div class="required">
<a name="main_con"></a><label for="name">Name*</label>
<input id="name" name="name" type="text" value="<?php echo $_POST["name"];?>">
</div>
<div class="required">
<label for="email">Email Address*</label>
<input id="email" name="email" type="text" value="<?php echo $_POST["email"];?>">
</div>
<div class="required">
<label for="telephone">Telephone*</label>
<input id="telephone" name="telephone" type="text" value="<?php echo $_POST["telephone"];?>">
</div>
<div>
<label for="time">Best time to call</label>
<input id="time" name="time" type="text" value="<?php echo $_POST["time"];?>">
</div>
<div>
<label for="company">Company</label>
<input id="company" name="company" type="text" value="<?php echo $_POST["company"];?>">
</div>
<div>
<label for="address">Address</label>
<textarea name="address" cols="20" rows="5" id="address"><?php echo $_POST["address"];?></textarea>
</div>
<div>
<label for="postcode">Post code</label>
<input id="postcode" name="postcode" type="text" value="<?php echo $_POST["postcode"];?>">
</div>
<div class="required">
<label for="enquiry">Nature of Enquiry*</label>
<select id="enquiry" name="enquiry">
<option value="">Please select...</option>
<option<?php echo ($_POST["enquiry"] == "Driving Instructor Training" ? ' selected="selected"' : '');?> value="Driving Instructor Training">Driving Instructor Training</option>
<option<?php echo ($_POST["enquiry"] == "Part 2 & 3 Rescue" ? ' selected="selected"' : '');?> value="Part 2 & 3 Rescue">Part 2 & 3 Rescue</option>
<option<?php echo ($_POST["enquiry"] == "Check Test Training" ? ' selected="selected"' : '');?> value="Check Test Training">Check Test Training</option>
<option<?php echo ($_POST["enquiry"] == "Fleet Trainer Diploma" ? ' selected="selected"' : '');?> value="Fleet Trainer Diploma">ADI Fleet Trainer Diploma</option>
<option<?php echo ($_POST["enquiry"] == "Advanced Driver Training" ? ' selected="selected"' : '');?> value="Advanced Driver Training">Advanced Driver Training</option>
<option<?php echo ($_POST["enquiry"] == "Fleet Driver Training" ? ' selected="selected"' : '');?> value="Fleet Driver Training">Fleet Driver Training</option>
<option<?php echo ($_POST["enquiry"] == "SAFED for Vans" ? ' selected="selected"' : '');?> value="SAFED for Vans">SAFED for Vans</option>
<option<?php echo ($_POST["enquiry"] == "General Query" ? ' selected="selected"' : '');?> value="General Query">General Query</option>
<option<?php echo ($_POST["enquiry"] == "Other" ? ' selected="selected"' : '');?> value="Other">Other</option>
</select>
</div>
<div class="required">
<label for="enquiry2">How can we help?*</label>
<textarea name="enquiry2" cols="20" rows="5" id="enquiry2"><?php echo $_POST["enquiry2"];?></textarea>
</div>
<div class="required">
<label for="howfound">How You Found Us*</label>
<select id="howfound" name="howfound">
<option value="">Please select...</option>
<option<?php echo ($_POST["howfound"] == "Search engine (Google, MSN, Yahoo! etc)" ? ' selected="selected"' : '');?> value="Search engine (Google, MSN, Yahoo! etc)">Search engine (Google, MSN, Yahoo! etc)</option>
<option<?php echo ($_POST["howfound"] == "Link on a website" ? ' selected="selected"' : '');?> value="Link on a website">Link on a website</option>
<option<?php echo ($_POST["howfound"] == "yell" ? ' selected="selected"' : '');?> value="Yell.com">Yell.com</option>
<option<?php echo ($_POST["howfound"] == "Recommendation" ? ' selected="selected"' : '');?> value="Recommendation">Recommendation</option>
<option<?php echo ($_POST["howfound"] == "Advert" ? ' selected="selected"' : '');?> value="Adver">Advert</option>
<option<?php echo ($_POST["howfound"] == "Other" ? ' selected="selected"' : '');?> value="Other">Other</option>
</select>
</div>
<div class="submit">
<div>
<input type="image" title="Send contact form" onMouseOver="this.src='images/send_over.gif'" onMouseOut="this.src='images/send.gif'" src="images/send.gif" alt="Send" name="submit" class="inputImage">
</div>
</div>
</fieldset>
</form>
<?php } else { ?>
<p>Thank you for contacting us! A member of our team will be in touch shortly.</p>
<?php } ?>
Hope you can help! Tried so many combinations here, just wondering where to put the recaptcha code that's here http://code.google.com/apis/recaptcha/docs/php.html ?
Any help would be much appreciated as it's been troubling me for couple of days!
<?php
// check if the newsletter form has been submitted
if ($_POST["Button"] == "EMail") {
$emailNotice = "";
if (empty($_POST["name"])) $emailNotice .= "Please enter your name<br>";
if (!eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $_POST["email"])) $emailNotice .= "Please enter a valid email address<br>";
if (empty($_POST["telephone"])) $emailNotice .= "Please enter your telephone number<br>";
if (empty($_POST["enquiry"])) $emailNotice .= "Please select the nature of your enquiry<br>";
if (empty($_POST["enquiry2"])) $emailNotice .= "Please describe how we can help you<br>";
if (empty($_POST["howfound"])) $emailNotice .= "Please select how you found our website<br>";
if (empty($emailNotice)) {
define("EMAILCONTACT", "claire@aditrainer.com");
// construct the email
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$headers .= 'To: ' . EMAILCONTACT . "\n";
$headers .= 'From: ' . EMAILCONTACT . "\n";
$subject = "IMPORTANT - Contact request from Active website";
$recipient = EMAILCONTACT;
$emailcontent = implode("", file("email/contactrequest.htm"));
$emailcontent = str_replace("|||NAME|||", htmlspecialchars($_POST["name"]), $emailcontent);
$emailcontent = str_replace("|||EMAIL|||", htmlspecialchars($_POST["email"]), $emailcontent);
$emailcontent = str_replace("|||COMPANY|||", htmlspecialchars($_POST["company"]), $emailcontent);
$emailcontent = str_replace("|||ADDRESS|||", str_replace("\n", "<br>", htmlspecialchars($_POST["address"])), $emailcontent);
$emailcontent = str_replace("|||POSTCODE|||", htmlspecialchars($_POST["postcode"]), $emailcontent);
$emailcontent = str_replace("|||TELEPHONE|||", htmlspecialchars($_POST["telephone"]), $emailcontent);
$emailcontent = str_replace("|||TIME|||", htmlspecialchars($_POST["time"]), $emailcontent);
$emailcontent = str_replace("|||ENQUIRY|||", htmlspecialchars($_POST["enquiry"]), $emailcontent);
$emailcontent = str_replace("|||ENQUIRY2|||", str_replace("\n", "<br>", htmlspecialchars($_POST["enquiry2"])), $emailcontent);
$emailcontent = str_replace("|||HOWFOUND|||", htmlspecialchars($_POST["howfound"]), $emailcontent);
// send the email
mail($recipient, $subject, $emailcontent, $headers);
$sThankyou = "thank you";
}
}
?>
<h1>Contact Us</h1>
<?php if ($sThankyou != "thank you") { ?>
<p class="strong">For information on any of our services, or to make a course booking, please complete the contact form below and we will contact you at a time to suit.</p>
<p>* required fields</p>
<?php if ($emailNotice) { ?>
<p><strong><?php echo $emailNotice;?></strong></p>
<?php } ?>
<form class="form" action="contact.php" method="post">
<input type="hidden" name="Button" value="EMail">
<fieldset>
<legend></legend>
<div class="required">
<a name="main_con"></a><label for="name">Name*</label>
<input id="name" name="name" type="text" value="<?php echo $_POST["name"];?>">
</div>
<div class="required">
<label for="email">Email Address*</label>
<input id="email" name="email" type="text" value="<?php echo $_POST["email"];?>">
</div>
<div class="required">
<label for="telephone">Telephone*</label>
<input id="telephone" name="telephone" type="text" value="<?php echo $_POST["telephone"];?>">
</div>
<div>
<label for="time">Best time to call</label>
<input id="time" name="time" type="text" value="<?php echo $_POST["time"];?>">
</div>
<div>
<label for="company">Company</label>
<input id="company" name="company" type="text" value="<?php echo $_POST["company"];?>">
</div>
<div>
<label for="address">Address</label>
<textarea name="address" cols="20" rows="5" id="address"><?php echo $_POST["address"];?></textarea>
</div>
<div>
<label for="postcode">Post code</label>
<input id="postcode" name="postcode" type="text" value="<?php echo $_POST["postcode"];?>">
</div>
<div class="required">
<label for="enquiry">Nature of Enquiry*</label>
<select id="enquiry" name="enquiry">
<option value="">Please select...</option>
<option<?php echo ($_POST["enquiry"] == "Driving Instructor Training" ? ' selected="selected"' : '');?> value="Driving Instructor Training">Driving Instructor Training</option>
<option<?php echo ($_POST["enquiry"] == "Part 2 & 3 Rescue" ? ' selected="selected"' : '');?> value="Part 2 & 3 Rescue">Part 2 & 3 Rescue</option>
<option<?php echo ($_POST["enquiry"] == "Check Test Training" ? ' selected="selected"' : '');?> value="Check Test Training">Check Test Training</option>
<option<?php echo ($_POST["enquiry"] == "Fleet Trainer Diploma" ? ' selected="selected"' : '');?> value="Fleet Trainer Diploma">ADI Fleet Trainer Diploma</option>
<option<?php echo ($_POST["enquiry"] == "Advanced Driver Training" ? ' selected="selected"' : '');?> value="Advanced Driver Training">Advanced Driver Training</option>
<option<?php echo ($_POST["enquiry"] == "Fleet Driver Training" ? ' selected="selected"' : '');?> value="Fleet Driver Training">Fleet Driver Training</option>
<option<?php echo ($_POST["enquiry"] == "SAFED for Vans" ? ' selected="selected"' : '');?> value="SAFED for Vans">SAFED for Vans</option>
<option<?php echo ($_POST["enquiry"] == "General Query" ? ' selected="selected"' : '');?> value="General Query">General Query</option>
<option<?php echo ($_POST["enquiry"] == "Other" ? ' selected="selected"' : '');?> value="Other">Other</option>
</select>
</div>
<div class="required">
<label for="enquiry2">How can we help?*</label>
<textarea name="enquiry2" cols="20" rows="5" id="enquiry2"><?php echo $_POST["enquiry2"];?></textarea>
</div>
<div class="required">
<label for="howfound">How You Found Us*</label>
<select id="howfound" name="howfound">
<option value="">Please select...</option>
<option<?php echo ($_POST["howfound"] == "Search engine (Google, MSN, Yahoo! etc)" ? ' selected="selected"' : '');?> value="Search engine (Google, MSN, Yahoo! etc)">Search engine (Google, MSN, Yahoo! etc)</option>
<option<?php echo ($_POST["howfound"] == "Link on a website" ? ' selected="selected"' : '');?> value="Link on a website">Link on a website</option>
<option<?php echo ($_POST["howfound"] == "yell" ? ' selected="selected"' : '');?> value="Yell.com">Yell.com</option>
<option<?php echo ($_POST["howfound"] == "Recommendation" ? ' selected="selected"' : '');?> value="Recommendation">Recommendation</option>
<option<?php echo ($_POST["howfound"] == "Advert" ? ' selected="selected"' : '');?> value="Adver">Advert</option>
<option<?php echo ($_POST["howfound"] == "Other" ? ' selected="selected"' : '');?> value="Other">Other</option>
</select>
</div>
<div class="submit">
<div>
<input type="image" title="Send contact form" onMouseOver="this.src='images/send_over.gif'" onMouseOut="this.src='images/send.gif'" src="images/send.gif" alt="Send" name="submit" class="inputImage">
</div>
</div>
</fieldset>
</form>
<?php } else { ?>
<p>Thank you for contacting us! A member of our team will be in touch shortly.</p>
<?php } ?>