<?php require_once("header.php");?>

<?php
if(isset($_POST['send']))
{	
	$sql_insert = "INSERT INTO `sc_enquiry` SET `name` = '".addslashes($_POST['name'])."',`email` = '".addslashes($_POST['email'])."',`phone` = '".addslashes($_POST['phone'])."',`message` = '".addslashes($_POST['message'])."',`post_date` = '".date('Y-m-d H:i:s',time())."'";
	$exe_insert = mysqli_query($connection,$sql_insert);
	
	$_SESSION['qp_succ_msg'] = 'Enquiry posted successfully.';
	header("location: post-enquiry.php");
	exit;
}
?>

		<script language="javascript" type="text/javascript">
		function form_validation()
		{
			if(document.getElementById('name').value == "")
			{
				alert("Please enter name");
				document.getElementById('name').focus();
				return false;
			}
			
			if(document.getElementById('phone').value == "")
			{
				alert("Please enter phone no.");
				document.getElementById('phone').focus();
				return false;
			}
			
			if(document.getElementById('message').value == "")
			{
				alert("Please enter message");
				document.getElementById('message').focus();
				return false;
			}
			
			return true;
		}
		</script>

		<!-- content area start -->
		<section id="about">
			<div class="container mt-0 pb-0 pt-10">	
				<div class="row">
					<div class="col-lg-12">
				        <h1 class="title mt-0 mb-10" style="text-align:center;">Post Enquiry</h1>
						<?php if(isset($_SESSION['qp_succ_msg'])) { ?>
						<p style="text-align:center; margin-bottom:10px;"><img src="images/tick.png" alt="" /> <?php echo $_SESSION['qp_succ_msg'];?></p>
						<?php 
						unset($_SESSION['qp_succ_msg']);
						} 
						?>	
						<form id="" action="" method="post" enctype="multipart/form-data" class="contact-form" onsubmit="return form_validation();">
						<div class="row">
							<div class="col-lg-12 form-group">
								<input name="name" id="name" placeholder="Enter Name *" class="common-input form-control" type="text">
							</div>
							<div class="col-lg-12 form-group">
								<input name="phone" id="phone" placeholder="Enter Phone No. *" class="common-input form-control" type="tel" maxlength="10">
							</div>
							<div class="col-lg-12 form-group">
								<input name="email" id="email" placeholder="Enter Email Address" class="common-input form-control" type="text">
							</div>
							<div class="col-lg-12 form-group">
								<textarea name="message" id="message" class="common-input form-control" placeholder="Enter Message *" style="height:150px;"></textarea>
							</div>
							<div class="col-lg-12 form-group">
								<button class="btn btn-flat btn-theme-colored border-left-theme-color-2-4px" type="submit" style="float: left;">Submit</button>
							</div>
						</div>
						<input type="hidden" name="send" id="send" value="1" />
						</form>	
					</div>
				</div>
			</div>	
		</section>
		<!-- content area end -->

<?php require_once("footer.php");?>