<?php
date_default_timezone_set('Asia/Kolkata');
include_once("include/main.inc.php"); 
date_default_timezone_set('Asia/Kolkata');
$date=date('Y-m-d H:i');

 @extract($_POST);
// print_r($_POST);
//exit; 
$admin_sql=mysqli_query($dbconn,"SELECT * FROM admin_details");
$admin_data=mysqli_fetch_array($admin_sql);
$referer = $_SERVER['HTTP_REFERER'];
$ip=$_SERVER['REMOTE_ADDR'];
  
if($qmobile!='' && $ip!='' && qname != '' ){
if(strlen($qmobile)==10){
 $sql_ens = "insert into tbl_enquiry set en_mobile='$qmobile', en_name='$qname', en_comment='Request A Call Back', en_url='$referer', en_date='$date', en_ip='$ip'";
$qry = mysqli_query($dbconn,$sql_ens);
//      print_r($qry);
//  print_r($_POST);
//exit; 
$subject = utf8_encode('Webpulseindia.com '.' - Contact No. '. $admin_data['subject']);
// $htmlContent = "
// Customer Details:

// Url: $referer

//  Your Name: " . $qname . "

// Mobile: " . $qmobile . "

// ";
$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;">' . $qname . '</span></td>
  </tr>
 <tr>
    <td width="26%">
      <strong>Contact No : </strong></td>
    <td>
      <span style="margin-top: 15px;">' . $qmobile . '</span></td>
  </tr>
</tbody>
        </table>';
    
$to =  $admin_data['email'];
$to2 = $admin_data['cc'];
$to3 = $admin_data['bcc'];
$email = 'enquiry@webpulseindia.com';
//  $to3 = 'developer.wpsrnc@gmail.com';
		
    // $headers = 'From: '.'Webpulseindia.com'.' enquiry@webpulseindia.com' . "\r\n" .
    //         'Reply-To:  '.$qname.'<'.$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);
    
        $res = '<div class="alert alert-success alert-dismissible  show">Your Contact No. has been sent successfully. Our Team will contact you shortly!<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>';

              

}
    else{
        $res = '<div class="alert alert-danger alert-dismissible show">Please Enter 10 Digit Mobile Number. <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"><span aria-hidden="true"></span></button></div>';
    }

}
	else {
			$res = '<div class="alert alert-danger">Asterisk(*) Marked fields are Mandatory.<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"><span aria-hidden="true"></span></button></div>';
	}

  
    echo $res;
    
    
?>