<?php
  include ("dbcnct.php");

  $FName = $_REQUEST['fname'];
  $LName = $_REQUEST['lname'];
  $FromEmail = $_REQUEST['email'];
  $Mobile = $_REQUEST['number'];
  $Subject = $_REQUEST['subject'];
  $Comments = $_REQUEST['message'];
  
  $deliveryemail = 'editoricelj@gmail.com';
  $to = $_REQUEST['email'];
    
  $date = date_default_timezone_set('Asia/Kolkatta');
  $today = date("F j, Y, g:i a T");
    
  $VerfiyEmail = $_REQUEST['vemail'];
    
  if($VerfiyEmail == '' && $FName!='' && $FromEmail!='' && $Mobile!='' && $Subject!='' && $Comments!='' ) {
    
    
    $query = mysqli_query($db_connect, 
    "INSERT into ICELA (UserTime,FirstName,LastName,Email,Mobile,Subject,Comments) values ('$today','$FName','$LName','$FromEmail','$Mobile','$Subject','$Comments')") or die(mysqli_error($db_connect));

 
   	$headers = 'MIME-Version: 1.0' . "\r\n";
	$headers .= "From: " . $deliveryemail . "\r\n"; // Sender's E-mail
	$headers .= "Cc:". $deliveryemail . "\r\n"; // Carbon copy to Sender
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	
    $Message ='
    <div class="row MailForm" style="box-shadow: 4px 2px 4px 4px solid #8295ff;width:700px;margin:auto;display:block;border:1px solid #bfbc00;">
        <div class="container">
            <div class="Mail_Header" style="background:#1343f0;border-bottom:1px solid #d4d4d6;padding:5px;">
                <p><img src="assets/img/icna.png" style="height:120px;width:120px;margin:auto;display:block;" /></p>
                <p style="color:#fff;">Hello Respected User,</p>
                <p style="color:#fff;">This is an Automatic mail from ICELJ, we have received your information from our website.</p>
            </div>
            <div class="Mail_Body" style="background:#fff;border-bottom:1px solid #2206bf;color:#000;">
        	    <p>Thank you for Contacting us. We received your Details as</p>
        		<table class="Tb_Border" border="1" style="min-width:100%;padding:5px;color:#000;">
        		    <tr style="padding:5px;">
        		        <td>First Name</td>
        		        <td style="color:#000;">'.$FName.' </td>
        		    </tr>
        		    <tr>
        		        <td>Last Name</td>
        		        <td style="color:#000;">'.$LName.' </td>
        		    </tr>
        		    <tr>
        		        <td>Organisation Name</td>
        		        <td style="color:#000;">'.$Mobile.' </td>
        		    </tr>
        		    <tr>
        		        <td>Job Title</td>
        		        <td style="color:#000;">'.$Subject.' </td>
        		    </tr>
        		    <tr>
        		        <td>Email Id</td>
        		        <td style="color:#000;">'.$to.'</td>
        		    </tr>
        		    <tr>
        		        <td>Mobile</td>
        		        <td style="color:#000;">'.$Comments.'</td>
        		    </tr>
        		</table>
    	    </div>
    	    <div class="Mail_Footer" style="background:#abacb3;color:#000;padding:10px;">
        		<p>For further details please share your words with us on <b style="color:#000;">editoricelj@gmail.com</b>.
        		<br>
        		Regards,
        		<br>
        		ICELJ.</p>
    		</div>
        </div>
    </div>
    ';
	

   if(@mail($to, $Emailfrom, $Message, $headers)){
		echo "We've received your query, we will get back to you soon.";
	}
	else{
		echo "Ohh !!! An error occurred, Please try again. Incovience regreeted.";
	}
    }
    else{
        echo "Fill All Mandatory Fields !";
    }
?>
