Download recaptch version 2 from https://github.com/google/ReCAPTCHA
Download recaptcha library from here
<script type="text/javascript">
var RecaptchaOptions = {
theme : 'clean'
};
</script>
<?php
include('recaptchalib.php');
$publickey = "6LewXewSAAAAANSyq3pKWEME8Yjeg2g6avlHdthN";
$privatekey = "6LewXewSAAAAAC70yiCqkyHoKHvxBrjUSXoATFNZ";
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
$errors = array();
$response_msg = '';
if(isset($_POST)&&sizeof($_POST)>0){
$email = $_POST['email'];
if(empty($_POST['your_name'])){
$errors['your_name'] ="Name is required";
}
if(empty($email)){
$errors['email'] ="Email is required";
}elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
$errors['email'] ="Please enter valid email address";
}
if(empty($_POST['message'])){
$errors['message'] ="Message is required field";
}
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$errors['captcha'] ="Please enter correct captcha";
}
$message ='<html>';
$message .='<head><title style="color:green">Contact form enquiry</title></head>';
$message .='<body>';
$message .='<table>';
$message .='<tr><td valign="top">Name</td><td>'.$_POST['your_name'].'</td></tr>';
$message .='<tr><td valign="top">Email</td><td>'.$_POST['email'].'</td></tr>';
$message .='<tr><td valign="top">Phone</td><td>'.$_POST['phone'].'</td></tr>';
$message .='<tr><td valign="top">Message</td><td>'.stripslashes($_POST['message']).'</td></tr>';
$message .='</table>';
$message .= "<p>This mail is sent via contact form of the site <a href='http://webalive.com.au/'>http://webalive.com.au/</a></p>";
$message .='</body>';
$message .='</html>';
$to = 'autobillsmtp@webalive.biz';
$bcc = '';
$subject = 'Contact us query';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: webalive.com.au <'.$email.'>'."\r\n" .
'Bcc:'.$bcc. "\r\n" .
'Reply-To: '.$email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(sizeof($errors)==0){
if(mail($to, $subject, $message, $headers)){
$response_msg ='<div class="response success-msg">Your message was sent successfully</div>';
}else{
$response_msg ='<div class="response error-msg">Mail is not sent.Please try again</div>';
}
}
}
$error = false;
$error_html = '';
if(sizeof($errors)){
$error_html .='<ul class="error">';
foreach($errors as $key=>$value){
$error_html .='<li>'.$value.'</li>';
}
$error_html .='</ul>';
$error = true;
}
?>
<div class="contact-form-wrapper">
<h3>Contact us</h3>
<?php
echo $response_msg;
echo $error_html;
?>
<form action="" method="post">
<table class="contact-us" id="quote-request-form" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" class="label">Name <span class="required">*</span></td>
<td valign="top" class="field">
<input type="text" name="your_name" value="<?php if($error){ echo $_POST['your_name']; } ?>" required/>
</td>
</tr>
<tr>
<td valign="top" class="label">Email <span class="required">*</span></td>
<td valign="top" class="field">
<input type="email" name="email" value="<?php if($error){ echo $_POST['email']; } ?>" required/>
</td>
</tr>
<tr>
<td valign="top" class="label">Phone</td>
<td valign="top" class="field">
<input type="text" name="phone" value="<?php if($error){ echo $_POST['phone']; } ?>" />
</td>
</tr>
<tr>
<td valign="top" class="label">Message <span class="required">*</span></td>
<td valign="top" class="field">
<textarea name="message" required><?php if($error){ echo $_POST['message']; } ?></textarea>
</td>
</tr>
<tr>
<td colspan="2" valign="top">
<div class="main_captcha"><?php echo recaptcha_get_html($publickey, $error); ?> </div>
</td>
</tr>
<tr>
<td colspan="2" valign="top">
<input type="submit" value="Send" />
</td>
</tr>
</table>
</form>
</div>
Download recaptcha library from here
<!-- theme options: white, red, blackglass, clean -->
<script type="text/javascript">
var RecaptchaOptions = {
theme : 'clean'
};
</script>
<?php
include('recaptchalib.php');
$publickey = "6LewXewSAAAAANSyq3pKWEME8Yjeg2g6avlHdthN";
$privatekey = "6LewXewSAAAAAC70yiCqkyHoKHvxBrjUSXoATFNZ";
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
$errors = array();
$response_msg = '';
if(isset($_POST)&&sizeof($_POST)>0){
$email = $_POST['email'];
if(empty($_POST['your_name'])){
$errors['your_name'] ="Name is required";
}
if(empty($email)){
$errors['email'] ="Email is required";
}elseif(!filter_var($email, FILTER_VALIDATE_EMAIL)){
$errors['email'] ="Please enter valid email address";
}
if(empty($_POST['message'])){
$errors['message'] ="Message is required field";
}
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$errors['captcha'] ="Please enter correct captcha";
}
$message ='<html>';
$message .='<head><title style="color:green">Contact form enquiry</title></head>';
$message .='<body>';
$message .='<table>';
$message .='<tr><td valign="top">Name</td><td>'.$_POST['your_name'].'</td></tr>';
$message .='<tr><td valign="top">Email</td><td>'.$_POST['email'].'</td></tr>';
$message .='<tr><td valign="top">Phone</td><td>'.$_POST['phone'].'</td></tr>';
$message .='<tr><td valign="top">Message</td><td>'.stripslashes($_POST['message']).'</td></tr>';
$message .='</table>';
$message .= "<p>This mail is sent via contact form of the site <a href='http://webalive.com.au/'>http://webalive.com.au/</a></p>";
$message .='</body>';
$message .='</html>';
$to = 'autobillsmtp@webalive.biz';
$bcc = '';
$subject = 'Contact us query';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: webalive.com.au <'.$email.'>'."\r\n" .
'Bcc:'.$bcc. "\r\n" .
'Reply-To: '.$email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(sizeof($errors)==0){
if(mail($to, $subject, $message, $headers)){
$response_msg ='<div class="response success-msg">Your message was sent successfully</div>';
}else{
$response_msg ='<div class="response error-msg">Mail is not sent.Please try again</div>';
}
}
}
$error = false;
$error_html = '';
if(sizeof($errors)){
$error_html .='<ul class="error">';
foreach($errors as $key=>$value){
$error_html .='<li>'.$value.'</li>';
}
$error_html .='</ul>';
$error = true;
}
?>
<div class="contact-form-wrapper">
<h3>Contact us</h3>
<?php
echo $response_msg;
echo $error_html;
?>
<form action="" method="post">
<table class="contact-us" id="quote-request-form" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" class="label">Name <span class="required">*</span></td>
<td valign="top" class="field">
<input type="text" name="your_name" value="<?php if($error){ echo $_POST['your_name']; } ?>" required/>
</td>
</tr>
<tr>
<td valign="top" class="label">Email <span class="required">*</span></td>
<td valign="top" class="field">
<input type="email" name="email" value="<?php if($error){ echo $_POST['email']; } ?>" required/>
</td>
</tr>
<tr>
<td valign="top" class="label">Phone</td>
<td valign="top" class="field">
<input type="text" name="phone" value="<?php if($error){ echo $_POST['phone']; } ?>" />
</td>
</tr>
<tr>
<td valign="top" class="label">Message <span class="required">*</span></td>
<td valign="top" class="field">
<textarea name="message" required><?php if($error){ echo $_POST['message']; } ?></textarea>
</td>
</tr>
<tr>
<td colspan="2" valign="top">
<div class="main_captcha"><?php echo recaptcha_get_html($publickey, $error); ?> </div>
</td>
</tr>
<tr>
<td colspan="2" valign="top">
<input type="submit" value="Send" />
</td>
</tr>
</table>
</form>
</div>