
PK 
<?php
// Checking valid form is submitted or not
if (isset($_POST['submit_btn'])) {
// Storing name in $name variable
$name = !empty($_POST['name'])?trim($_POST['name']):"";
$email = !empty($_POST['email'])?trim($_POST['email']):"";
$message = !empty($_POST['message'])?trim($_POST['message']):"";
$error_msg = "";
// Storing google recaptcha response
// in $recaptcha variable
$recaptcha = $_POST['g-recaptcha-response'];
// Put secret key here, which we get
// from google console
$secret_key = '6LcS11spAAAAAOm9h1b7Nd21dhSdYo0bUN8jYFwd';
// Hitting request to the URL, Google will
// respond with success or error scenario
$url = 'https://www.google.com/recaptcha/api/siteverify?secret='
. $secret_key . '&response=' . $recaptcha;
// Making request to verify captcha
$response = file_get_contents($url);
// Response return by google is in
// JSON format, so we have to parse
// that json
$response = json_decode($response);
// Checking, if response is true or not
if ($response->success == true) {
//mail to admin for contacting users
function sendmail($name,$from,$to,$sendmessage){
$from = 'info@taattva.in';
$to = $to;//'indusinfotek.vinay@gmail.com';
$subject = 'Taattva Enquiry';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From:' .$from. "\r\n" .
'Reply-To: ' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$message = $sendmessage;
mail($to, $subject, $message, $headers);
}
if(!empty($message)){
$to="dutta.krishnendu@gmail.com";
$contactmail='<table cellpadding="0" cellspacing="0" style="width:600px; margin:0px auto; color:#7b7b7c; vertical-align:middle; font-family:Arial, Helvetica, sans-serif; font-size:16px;">
<tr>
<td style="text-align:center;"><a href="#"><img src="" /></a></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td style="color:#333;"><strong>Hi, Admin</strong></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>You have been received a query.</td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" style="width:600px; margin:0px auto; color:#7b7b7c; vertical-align:top; font-family:Arial, Helvetica, sans-serif; font-size:14px; line-height:22px;">
<tr>
<td> </td>
</tr>
<tr>
<td style="color:#333;" colspan="3"><strong>Contact Details</strong></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td width="200px;">Name</td>
<td width="20px;">:</td>
<td width="380px;">'.$name.'</td>
</tr>
<tr>
<td width="200px;">Email Address</td>
<td width="20px;">:</td>
<td width="380px;">'.$email.'</td>
</tr>
<tr>
<td width="200px;">Requirements</td>
<td width="20px;">:</td>
<td width="380px;"><p>'.$message.'</p></td>
</tr>
</table>';
//print_r($contactmail); exit;
sendmail($name,$from,$to,$contactmail);
}
// end mail send
$error_msg = "Message Sent Successfully";
echo '<script>alert("Message Sent Successfully")</script>';
} else {
$error_msg = "Error in Google reCAPTACHA";
echo '<script>alert("Error in Google reCAPTACHA")</script>';
}
}
?>


PK 99