<?php 
require_once 'admin-neuro/lib/Config.php';
?>
   <?php
   
      			// Import PHPMailer classes into the global namespace 
use PHPMailer\PHPMailer\PHPMailer; 
use PHPMailer\PHPMailer\SMTP; 
use PHPMailer\PHPMailer\Exception; 

// Include PHPMailer library files 
require 'PHPMailer/Exception.php'; 
require 'PHPMailer/PHPMailer.php'; 
require 'PHPMailer/SMTP.php'; 	
 
	if(isset($_POST['submit'])){
	 extract($_POST);
	 
	 if ($email && ( empty(stripos(strtolower($email), '@example'))   ))

			$_SESSION['name']=$name;
						$_SESSION['email']=$email;
						
						$_SESSION['aemail']=$aemail;
						
						$_SESSION['phone']=$phone;
						$_SESSION['wphone']=$wphone;
						
						$_SESSION['institution']=$institution;
						
						$_SESSION['country']=$country;
						
						$_SESSION['presentation']=$presentation;
						
						$_SESSION['participants']=$participants;
						
						$_SESSION['regtype']=$regtype;
						
						$_SESSION['accomm']=$accomm;
						
						$_SESSION['checkin']=$checkin;
						
						$_SESSION['checkout']=$checkout;
						
						$_SESSION['nights']=$nights;
						
						$_SESSION['accm']=$accm;
						$_SESSION['acmpng']=$acmpng;
						
						$_SESSION['acc_pr']=$acc_pr;
						
						$_SESSION['tot_price']=$tot_price;
						date_default_timezone_set('Asia/Kolkata');
                        $now = date("Y-m-d H:i:s");
			
			//print_r($_SESSION);
		$pr=explode('_',$regtype);	
		$price=$pr[1];
		if(isset($_POST['acc_person'])){
		$acc=explode('_',$accperson);	
		$accprice=$acc[1];				
		}else{$acc_person='';	$accprice='';}


$arr=array('name' 		=> addslashes($name),'email' 		=> addslashes($email),'aemail' 		=> addslashes($aemail),'phone' 		=> addslashes($phone),'wphone' 		=> addslashes($wphone),
'institution' 		=> addslashes($institution),'country' 		=> addslashes($country),'presentation' 		=> addslashes($presentation),
'participants' 		=> addslashes($participants),'regtype' 		=> addslashes($regtype),'accomm' 		=> addslashes($accomm),
'checkin' 		=> addslashes($checkin),'checkout' 		=> addslashes($checkout),'nights' 		=> addslashes($nights),'accm' 		=> addslashes($accm),
'acmpng' 		=> addslashes($acmpng),'acc_pr' 		=> addslashes($acc_pr),'tot_price' 		=> addslashes($tot_price),'now' 		=> addslashes($now),'status'=>1);

	$DB->insert('acc_registrations',$arr);
	
		
	                            
$id=getRecordId();
	$regi_id=mysqli_insert_id();
$_SESSION['regi_id']=$id;	

// Create an instance of PHPMailer class 
$mail = new PHPMailer;
$to   = getRecord('id','mails','4','email');
// SMTP configuration
// $mail->isSMTP();
$mail->Host     = 'smtp.neurologyworldconference.com';
$mail->SMTPAuth = true;
$mail->Username = 'info@neurologyworldconference.com';
$mail->Password = 'addiction@123';
$mail->SMTPSecure = 'tls';
$mail->Port     = 25;

// Sender info 
$mail->setFrom('info@neurologyworldconference.com', 'Admin'); 
//$mail->addReplyTo('reply@example.com', 'SenderName');  

// Add a recipient 
$mail->addAddress($to); 

// // Add cc or bcc  
// $mail->addCC('cc@example.com'); 
// $mail->addBCC('bcc@example.com'); 
 
// Email subject 
$mail->Subject = 'Neurology World Conference Registration Form'; 

// // Set email format to HTML 
 $mail->isHTML(true); 
 
// Email body content 
$mailContent = ' 
             <h2>Neurology World Conference Registration Request Details</h2> 
            
            <table border="1">
<tr><td>Name:</td><td>'.$name.'</td></tr>			
<tr><td>Email Id:</td><td>'.$email.'</td></tr>
<tr><td>Alternative Email Id:</td><td>'.$aemail.'</td></tr>
<tr><td>Phone No:</td><td>'.$phone.'</td></tr>	
<tr><td>WhatsApp Phone No:</td><td>'.$wphone.'</td></tr>
<tr><td>Accommodation Price:</td><td>'.$accomm.'</td></tr>
<tr><td>Checkin Date:</td><td>'.$checkin.'</td></tr>
<tr><td>Checkout Date:</td><td>'.$checkout.'</td></tr>
<tr><td>Number of Nights:</td><td>'.$nights.'</td></tr>
<tr><td>Total Accomodation Price:</td><td>'.$accm.'</td></tr>
<tr><td>Total Price:</td><td>'.$tot_price.'</td></tr></table>
   '; 
$mail->Body = $mailContent; 

// // Add attachments
// $mail->addAttachment('files/codexworld.pdf');
// $mail->addAttachment('images/codexworld.png', 'new-name.png'); //set new name
 
// Send email 

if ($email && ( empty(stripos(strtolower($email), '@example'))   )){
   
    if(!$mail->send()){ 
        echo 'Message could not be sent. Mailer Error: '.$mail->ErrorInfo; 
    }else{
   ?>
   
   <script>
        
        window.location="accommodation-proceed-pay.php";
        </script>

  <?php 
    exit;
    }   
}else{?>
<script>
    alert("Sorry!,  Some technical issue. try after sometime..");
    window.location ="accommodation.php";
    </script>
<?php } 




	}
?>