<?php
    $page = "login" ;
    include 'head.php';
    session_start();

if(isset($_POST['submit'])){
	$name = $_POST['name'];
	$email = $_POST['email'];
	$phone = $_POST['phone'];
	$subject = $_POST['subject'];
	// $courseDate = $_POST['courseDate'];
	$message = $_POST['message'];
	$message1 = $_POST['message'];

	$to=$email;
	$ticket_no = $subject;
	$subject = "Your Enquiry - ".$ticket_no;
	$headers = "MIME-Version: 1.0" . "\r\n";
	$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
	// More headers
	$headers .= "From: admin@addmyentry.com \r\n";
	$message = 'Dear '. $name.',<br/><br/>';
	$message.='Thank you for your Interest. Your enquiry was submitted successfully, our representative will reach you as soon as possible.';
	$message.='
	</table>
	<br/><br/>
	<b>Regards,</b><br/>
	Addmyentry<br/>
	https://addmyentry.com/';
	if(mail($to,$subject,$message,$headers) == true){
		$sql = "INSERT INTO enquiry(name,email,phone,subject,message)VALUES('$name','$email','$phone','$subject','$message1')";
		
		$to = "admin@addmyentry.com" ;
    	$headers = "MIME-Version: 1.0" . "\r\n";
    	$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
    	$headers .= "From: admin@addmyentry.com \r\n";
    	
    	$message = 'Name : '. $name.',<br/>';
    	$message .= 'Mobile Number : '. $phone.',<br/>';
    	$message .= 'Email : '. $email.',<br/><br/>';
    	$message .= $subject.',<br/><br/>';
    	$message .= '&nbsp;&nbsp;&nbsp;'.$message.'<br/><br/>
    	<b>Regards,</b><br/>
    	Addmyentry<br/>
    	https://addmyentry.com/';
		$new = mail($to,$subject,$message,$headers);

		if($config->query($sql)){
		    $_SESSION['status'] = "Your enquiry has been submitted successfully. Thank you!"  ;
		    $_SESSION['alert'] = "success"  ;
		}else{
		    $_SESSION['status'] = "Please try again."  ;
		    $_SESSION['alert'] = "error"  ;
		}
 	}
}

?>   
<link rel="stylesheet" href="custom.css">
	<body>

		<!-- Main Wrapper -->
		<div class="main-wrapper">
		
			<!-- Header -->
			<?php include('./header.php') ?>
			<!-- /Header -->
			
		<!-- Page Content -->
					
			<!-- /Page Content -->
    <section class="contact-area pt-5" style="background:#eee;">
        <div class="container">
            <div class="row">
                <div class="col-lg-7 mb-5 pb-5">
                    <div class="card" style="border:unset;">
                        <div class="card-body">
                            <h2 class="form-heading">Contact Us</h2>
                            <h5 class="form-title">Keep In Touch</h5>
                            <form  method="post">
                                <div class="row">
                                    <div class="col-lg-6">
                                        <div class="form-group">
                                            <input type="text" class="form-us" id="name" name="name" placeholder="Your Name" required>
                                        </div>
                                    </div>
                                    <div class="col-lg-6">
                                        <div class="form-group">
                                            <input type="email" class="form-us" id="email" name="email" placeholder="Your E-mail" required>
                                        </div>
                                    </div>
                                    <div class="col-lg-6">
                                        <div class="form-group">
                                            <input type="text" class="form-us" id="phone" name="phone" placeholder="Your Mobile Number" maxlength='10' onKeyPress="if(this.value.length==10) return false;" required>
                                        </div>
                                    </div>
                                    <div class="col-lg-6">
                                        <div class="form-group">
                                            <input type="text" class="form-us" id="subject" name="subject" placeholder="Your Subject" required>
                                        </div>
                                    </div>
                                    <div class="col-12">
                                        <div class="form-group">
                                            <textarea name="message" class="form-us" id="message" name="message" cols="30" rows="7" placeholder="Your Message" required style="resize:none;"></textarea>
                                        </div>
                                    </div>
                                    <div class="col-12">
                                        <button class="btn btn-warning mt-30 text-white" type="submit" name="submit">Send</button>
                                    </div>
                                    
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                
                <div class="col-lg-5 mb-5">
                    <div class="card" style="border:unset;">
                        <?php
					        $contact_sql = "SELECT * FROM contact_master WHERE c_status = 1 " ;
					        $contact_res = $config->query($contact_sql);
					        $contact = $contact_res->fetch_assoc();
					    ?>
                        <div class="card-body" style="padding-bottom:30px;">
                            <h4 class="form-heading">Communication Info</h4>
                            <address class="d-flex info" style="margin-bottom:0px;">
                                <i class="fas fa-map-marker-alt" style="line-height: 2;"></i>
                                <p><?= $contact['c_address'] ?></p>
                            </address>
                            <div class="d-flex info">
                                <i class="fas fa-phone" style="line-height: 2;"></i>
                                <p>+91 <?= $contact['c_mobile'] ?></p>
                            </div>
                            <div class="d-flex info" >
                                <i class="fas fa-envelope" style="line-height: 2;"></i>
                                <p><?= $contact['c_email_id'] ?></p>
                            </div>
                            <div class="d-flex map-info">
                                <?= $contact['c_map'] ?>
                            </div>
                            
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- ##### Google Maps ##### -->
    </section>
			<!-- Footer -->
		
	        <?php include "footer.php" ;?>
			<!-- /Footer -->
		   
		</div>
		<!-- /Main Wrapper -->
	    <!-- custom style -->
		<!-- jQuery -->
		<script src="assets/js/jquery.min.js"></script>
		
		<!-- Bootstrap Core JS -->
		<script src="assets/js/popper.min.js"></script>
		<script src="assets/js/bootstrap.min.js"></script>
		
		<!-- Custom JS -->
		<script src="assets/js/script.js"></script>

		<script>
    <?php 
        if(isset($_SESSION['status']) && !empty($_SESSION['status'])){
    ?>
        swal({
          title: "",
          text: "<?= $_SESSION['status'] ?>",
          icon: "<?= $_SESSION['alert'] ?>",
        });
    <?php session_unset();} ?>
    </script>
	</body>

<!-- doccure/login.html  30 Nov 2019 04:12:20 GMT -->
</html>