<?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_res=mysqli_fetch_array($admin_sql);
$referer = $_SERVER['HTTP_REFERER'];
$ip=$_SERVER['REMOTE_ADDR'];
if (filter_var($email_subscribe, FILTER_VALIDATE_EMAIL)) {
$type = "Email Subscription" ;    
$sql_ens = "insert into tbl_enquiry set en_name='$user_name', en_email='$email_subscribe', en_mobile='$phone_no', en_country='$location', en_comment='$type', en_url='$referer', en_date='$date', en_ip='$ip'";
   
$qry = mysqli_query($dbconn,$sql_ens);
        
$subject = utf8_encode('Webpulseindia.com '.' - '. $admin_res['subject']);
$htmlContent = "
Customer Details:

Email Subscription: " . $email_subscribe . "";
            
$to =  $admin_res['email'];
$to2 = $admin_res['cc'];
$to3 = $admin_res['bcc'];

		
	  $headers = "MIME-Version: 1.0" . "\r\n";
             $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
                  // More headers
                  //$headers .= 'From:'.$name.' <'.$email.'>' . "\r\n";
                  $headers = 'From: '.'Webpulseindia.com'.$admin_res['email']. "\r\n" .
            'Reply-To:  '.$first_name.'<'.$email_subscribe.'>' . "\r\n" .
            'X-Mailer: PHP/' . phpversion();
	        @mail($to,$subject,$htmlContent,$headers);
			@mail($to2,$subject,$htmlContent,$headers);
			@mail($to3,$subject,$htmlContent,$headers);
            @mail($to4,$subject,$htmlContent,$headers);

            $res = '<div class="alert alert-success alert-dismissible  show">Email Subscribe successfully<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"><span aria-hidden="true"></span></button></div>';
        
            $email_subscribe='';
}
    else{
       $res = '<div class="alert alert-danger alert-dismissible show">Invalid Email Format <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"><span aria-hidden="true"></span></button></div>';  
    }
 echo $res;
    
?>