<div class="left_sidebar" id="sidebar">
    <?php
    include_once ("include/main.inc.php"); 
    $home_sql=mysqli_query($GLOBALS['dbcon'],"select * from static_pages where pageID='2'");
    $home_res=mysqli_fetch_array($home_sql);
    $admin_sql=mysqli_query($GLOBALS['dbcon'],"select * from admin_details");
    $admin_res=mysqli_fetch_array($admin_sql);
    $referer = $_SERVER['HTTP_REFERER'];
    $ip=$_SERVER['REMOTE_ADDR'];
    $mobileNumber = "";
    if (isset($_POST['submit-side']))
    {
        $name = !empty($_POST['names'])?$_POST['names']:'';
        $email = !empty($_POST['emails'])?$_POST['emails']:'';
        $mobileNumber = (!empty($_POST['mobiles']))?$_POST['mobiles']:'';
        $locations = !empty($_POST['locations'])?$_POST['locations']:'';
        $message = !empty($_POST['messages'])?$_POST['messages']:'';
        
        if(strpos($message,'#')!==false || strpos($message,'%')!==false || strpos($message,'@')!==false || strpos($message,'&')!==false || strpos($message,'~')!==false || strpos($message,'https')!==false || strpos($message,'http')!==false || strpos($message,'www')!==false || strpos($message,'?')!==false){
      $errMsgs ='URL(s) and special characters are not allowed!';
  } else { 
            
            if($name != '' && $email != '' && $mobileNumber != '' && $locations != '' && $message != '' && $ip != '' ){

//$qry=mysql_query($sql_ens);	
	//reCAPTCHA validation
               if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])) {

                $secret = secret_key;
		//get verify response data
        $data = array( 'secret' => $secret, 'response' => $_POST['g-recaptcha-response'] ); $verify = curl_init(); curl_setopt($verify, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify"); curl_setopt($verify, CURLOPT_POST, true); curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($verify, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($verify); //var_dump($response);
        $response = json_decode($response);
        
        if (!$response->success) {
            $errMsgs = 'Please click on the reCAPTCHA box.';
        }	
        
        if($response->success) {

            $sql_ens="insert into tbl_enquiry set en_name='$name', en_email='$email', en_mobile='$mobileNumber', en_country='$locations', en_comment='$message', en_url='$referer', en_date=now()";
            $qry=mysqli_query($GLOBALS['dbcon'],$sql_ens);

            $subject = utf8_encode('Webpulseindia.com '.' - '. $admin_res['subject']);
            // $htmlContent = "
            // Customer Details:

            // Url: ".$referer."

            // Name: ".$name."

            // Email: ".$email."

            // Mobile: ".$mobileNumber."

            // Location:".$locations."

            // Message: ".$message."
            // ";
            $htmlContent =  '<table border="0" width="100%">
        <tbody>
  <tr>
    <td colspan="2">
      <strong>Dear Admin</strong></td>
  </tr>
  <tr>
    <td colspan="2">
      Enquiry Received with following info :</td>
  </tr>
  <tr>
    <td colspan="2">
      &nbsp;</td>
  </tr>
  <tr>
    <td width="26%">
      <strong>Post URL : </strong></td>
    <td>
      <span style="margin-top: 15px;">' . $referer . '</span></td>
  </tr>
   <tr>
    <td width="26%">
      <strong>Name : </strong></td>
    <td>
      <span style="margin-top: 15px;">' . $name . '</span></td>
  </tr>
  <tr>
    <td width="26%">
      <strong>Email Id : </strong></td>
    <td>
      <span style="margin-top: 15px;">' . $email . '</span></td>
  </tr>

  <tr>
    <td width="26%">
      <strong>Contact No : </strong></td>
    <td>
      <span style="margin-top: 15px;">' . $mobileNumber . '</span></td>
  </tr>
  <tr>
    <td>
      <strong>Location : </strong></td>
    <td>
      <span style="margin-top: 15px;">' . $locations . '</span></td>
  </tr>
  <tr>
    <td>
      <strong>Message : </strong></td>
    <td>
      <span style="margin-top: 15px;">' . $message . '</span></td>
  </tr>
</tbody>
       
        </table>';
            
            // $to = $admin_res['email'];
            // $to2 = $admin_res['cc'];
            // $to3 = 'webpulseindia@gmail.com'; 
        // $to3 = 'developer.wpsrnc@gmail.com';

        $to3 = 'tanuja.wpsrnc@gmail.com';
            
            // $headers = 'From: '.'Webpulseindia.com'.' enquiry@webpulseindia.com' . "\r\n" .
            // 'Reply-To:  '.$name.'<'.$email.'>' . "\r\n" .
            // 'X-Mailer: PHP/' . phpversion();
            // @mail($to,$subject,$htmlContent,$headers);
            // @mail($to2,$subject,$htmlContent,$headers);
            // @mail($to3,$subject,$htmlContent,$headers);
            if($to!='')
         {
         smtp_mailer($to, $email, $name, $subject, $htmlContent);
         }
         if($to2!='')
         {
         smtp_mailer($to2, $email, $name, $subject, $htmlContent);
         }
   
         smtp_mailer($to3, $email, $name, $subject, $htmlContent);
            $succMsg = 'Thank you for your enquiry. Our team will contact you soon.';
$name = '';
$email = '';
$mobileNumber = '';
$locations = '';
$message = '';    

 }  
} else { $errMsgs ='Robot verification failed, please try again.';}
} else { $errMsgs ='All the fields are Mandatory!';}
  
}
}
?>
    <div class="left_title">Quick Contact</div>
    <form name="contact-form" method="post" id="quick_form">
    <?php if(!empty($errMsg)): ?><div class="alert alert-danger"><?php echo $errMsg; ?></div><?php endif; ?>
<?php if(!empty($succMsg)): ?><div class="alert alert-success"><?php echo $succMsg; ?></div><?php endif; ?>
        <div class="form-group">
        <input placeholder="Full Name *" class="form-control" type="text" tabindex="1" name="names" id="names" value="<?php echo !empty($name)?$name:''; ?>" onkeyup="validateOnlyTextField(this)" required="">
    </div>

    <div class="form-group">
        <input placeholder="Email ID *" class="form-control" type="email" tabindex="2" name="emails" id="emails" value="<?php echo !empty($email)?$email:''; ?>" required="">
    </div>
    <!-- <div class="form-group">

        <input placeholder="Phone Number *" class="form-control" type="tel" maxlength="10" tabindex="3" name="mobiles" id="mobiles" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"
oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" value="<?php echo (!empty($mobileNumber))?$mobileNumber:''; ?>" required="">
    </div> -->
    <div class="form-group">
				<input type="hidden" class="countryName countryName" name="countryName" value="">
				<input class="form-control telePhone mobile" value="" type="tel" name="mobile" placeholder="Mobile Number*" onkeyup="if (/\D/g.test(this.value)) this.value = this.value.replace(/\D/g,'')" minlength="10" maxlength="12" required="" autocomplete="off" style="padding-left: 84px;">
			</div>
    <div class="form-group">
        <input placeholder="Location*" class="form-control" type="text" tabindex="4" name="locations" value="<?php echo !empty($locations)?$locations:''; ?>" required="" pattern="[a-z A-Z]+">
    </div>

    <div class="form-group">
        <textarea placeholder="Type your Message Here...." class="form-control" required="" tabindex="5" name="messages" id="messages"><?php echo !empty($message)?$message:''; ?></textarea>
    </div>
    <div class="form-group" style="margin-bottom: 0;">
        
            <div tabindex="106" class="g-recaptcha" data-sitekey="<?=site_key;?>"></div>
    </div>
    <div class="form-group">
    <button type="submit" class="modal_btn" name="submit-side"  data-submit="...Sending">Submit</button>
    </div>
</form>
</div>

