
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']):"";
$contactno = !empty($_POST['contactno'])?trim($_POST['contactno']):"";
$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;">Contact no</td>
<td width="20px;">:</td>
<td width="380px;">'.$contactno.'</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>';
}
}
?>
<div class="row">
<div class="col-md-12">
<h1 class="text-center heading"><a name="connect">Connect</a></h1>
</div>
<div class="col-md-12">
<div class="contact">
<?=$contactdata[0]['contact_details'];?>
</div>
</div>
</div>
<div class="row connect-section justify-content-md-center">
<div class="col-md-7">
<div id="sendmessage" class="message_success" style="display:none;">Your message has been sent. Thank you!</div>
<div id="errormessage"></div>
<form action="action.php" method="post" id="reused_form">
<div class="row justify-content-md-center">
<div class="col-md-12">
<div class="form-group">
<input type="text" class="form-control field-label" id="name" name="name" required placeholder="Enter your name">
</div>
</div>
</div>
<div class="row justify-content-md-center">
<div class="col-md-12">
<div class="form-group">
<input type="email" class="form-control field-label" id="email" name="email" required pattern="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-z]{2,4}" placeholder="Enter your email">
</div>
</div>
</div>
<div class="row justify-content-md-center">
<div class="col-md-12">
<div class="form-group">
<input type="tel" class="form-control field-label" id="contactno" name="contactno" required placeholder="Enter your Phone Number">
</div>
</div>
</div>
<div class="row justify-content-md-center">
<div class="col-md-12">
<textarea class="form-control field-label" id="message" name="message" rows="4" required placeholder="Write to us:"></textarea>
</div>
</div>
<div class="row ustify-content-md-center" style="margin-bottom:30px; margin-top:15px;">
<div class="col-sm-12">
<!-- div to show reCAPTCHA -->
<div class="g-recaptcha"
data-sitekey="6LcS11spAAAAAPd7Qttx-VrL9yP0tjZdUNWblgxh">
</div>
</div>
</div>
<div class="row justify-content-md-center">
<!-- <div class="col-md-3 offset-md-3 order-firs pt-10">
<div class="form-group">
<input type="file" class="form-control-file" name="file" value="Attach Image" id="file">
</div>
</div> -->
<div class="col-md-6 pt-10">
<div class="form-group">
<!-- <button type="submit" class="btn btn-secondary btn-lg" id="sendbtn">Send Message</button> -->
<!--<button type="submit" class="btn btn-danger"><span>Send Message</span> </button>-->
<button type="submit" class="btn btn-danger btn-lg" id="sendbtn" name="submit_btn">Send Message</button>
</div>
</div>
</div>
<div class="row justify-content-md-center">
<div class="col-md-12 mx-auto">
<div id="errormessage"></div>
<div id="success_message" style="width:100%; height:100%; display:none; ">
<h3>Sent your message successfully!</h3>
</div>
</div>
</div>
</form>
</div>
</div>
<script type="text/javascript">
$("#reused_form").validate({
rules: {
name: {
required: true
},
contactno: {
required: true,
minlength: 10,
maxlength: 10,
digits: true
},
captcha: {
required: true
},
message: {
required: true
},
email: {
required: true,
email: true
}
},
messages: {
name: {
required: "Please enter name"
},
contactno: {
required: "Please enter contact number",
minlength: "Please enter minimum 10 digits number only",
maxlength: "Please enter maximum 10 digits number only",
digits: "Please enter digits only"
},
message: {
required: "Please enter message"
},
captcha: {
required: "Please enter captcha code"
},
email: {
required: "Please enter email",
email: "Please enter valid email"
}
},
submitHandler: function(form) {
form.submit();
}
});
</script>


PK 99