<?php include('_header.php'); 

$status = '';
if ( isset($_POST['captcha']) && ($_POST['captcha']!="") ){
	// Validation: Checking entered captcha code with the generated captcha code
	if(strcasecmp($_SESSION['captcha'], $_POST['captcha']) != 0){
		// Note: the captcha code is compared case insensitively.
		// if you want case sensitive match, update the check above to strcmp()
		$status = "<p style='color:#FFFFFF; font-size:20px'><span style='background-color:#FF0000;'>Entered captcha code does not match! Kindly try again.</span></p>";
		$success=0;
	}else{
		
		if(isset($_REQUEST['acivate'])){
	
			$full_name=mysqli_escape_string($conn, $_REQUEST['full_name']);
			$email=mysqli_escape_string($conn, $_REQUEST['email']);
			$phone=mysqli_escape_string($conn, $_REQUEST['phone']);
			$subject=mysqli_escape_string($conn, $_REQUEST['subject']);
			$message=mysqli_escape_string($conn, $_REQUEST['message']);
			
			
					$sql="INSERT INTO feedback_tbl VALUES ('',now(),'$email','$phone','$full_name','$subject','$message')"; 			
					mysqli_query($conn, $sql) or die(mysqli_error($conn));
					
					$success=1;
					//$msg="<font color=\"#0066CC\">Thank for your message...</font>"; 
					$status = "<p style='color:#FFFFFF; font-size:20px'><span style='background-color:#46ab4a;'>Thank you for completing our contact form!</span></p>";
								
			
		}
	}
}
?>

  <main class="main">

    <!-- Hero Section -->
    <section id="contact" class="hero section dark-background">

      <br/><br/><br/>

      <svg class="hero-waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28 " preserveAspectRatio="none">
        <defs>
          <path id="wave-path" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z"></path>
        </defs>
        <g class="wave1">
          <use xlink:href="#wave-path" x="50" y="3"></use>
        </g>
        <g class="wave2">
          <use xlink:href="#wave-path" x="50" y="0"></use>
        </g>
        <g class="wave3">
          <use xlink:href="#wave-path" x="50" y="9"></use>
        </g>
      </svg>

    </section><!-- /Hero Section -->
	
	
    <section id="contact" class="contact section">

      <!-- Section Title -->
      <div class="container section-title" data-aos="fade-up">
        <h2>Contact</h2>
        <p>Contact Us</p>
      </div><!-- End Section Title -->

      <div class="container" data-aos="fade" data-aos-delay="100">

        <div class="row gy-4">

          <div class="col-lg-4">
            <div class="info-item d-flex" data-aos="fade-up" data-aos-delay="200">
              <i class="bi bi-geo-alt flex-shrink-0"></i>
              <div>
                <h3>Address</h3>
                <p>
<?php
$query5  = "SELECT * FROM page_tbl WHERE  page_name = 'address'";
$result5 = mysqli_query($conn, $query5) or die(mysqli_error($conn));	
$info5 = mysqli_fetch_array($result5);
$text = $info5['text'];
$text = str_replace("\n", '<br />', $text);	
print $text;
?> 				
				</p>
              </div>
            </div><!-- End Info Item -->

            <div class="info-item d-flex" data-aos="fade-up" data-aos-delay="300">
              <i class="bi bi-telephone flex-shrink-0"></i>
              <div>
                <h3>Call Us</h3>
                <p>
<?php
$query5  = "SELECT * FROM page_tbl WHERE  page_name = 'phone'";
$result5 = mysqli_query($conn, $query5) or die(mysqli_error($conn));	
$info5 = mysqli_fetch_array($result5);
$text = $info5['text'];
$text = str_replace("\n", '<br />', $text);	
print $text;
?>				
				</p>
              </div>
            </div><!-- End Info Item -->

            <div class="info-item d-flex" data-aos="fade-up" data-aos-delay="400">
              <i class="bi bi-envelope flex-shrink-0"></i>
              <div>
                <h3>Email Us</h3>
                <p>
<?php
$query5  = "SELECT * FROM page_tbl WHERE  page_name = 'email'";
$result5 = mysqli_query($conn, $query5) or die(mysqli_error($conn));	
$info5 = mysqli_fetch_array($result5);
$text = $info5['text'];
$text = str_replace("\n", '<br />', $text);	
print $text;
?>					
				</p>
              </div>
            </div><!-- End Info Item -->

          </div>

          <div class="col-lg-8">
<?php
if(isset($status)){
	print $status;
}							
?> 

            <form action="contact.php" method="post"  data-aos="fade-up" data-aos-delay="200">
              <div class="row gy-4">

                <div class="col-md-12">				  
				  <input type="text" name="full_name"  placeholder="Your Name" class="form-control"
					<?php if((isset($success))&&($success==0)){ print " value=\"$_REQUEST[full_name]\" "; } ?> required >
                </div>

                <div class="col-md-6 ">
				  <input type="email" name="email" placeholder="Your Email" class="form-control"
                                <?php if((isset($success))&&($success==0)){ print " value=\"$_REQUEST[email]\" "; } ?> required  >
                </div>
				
				<div class="col-md-6 ">
				<input type="text" name="phone" placeholder="Phone number"class="form-control" 
                                <?php if((isset($success))&&($success==0)){ print " value=\"$_REQUEST[phone]\" "; } ?> required >
				</div>
				
                <div class="col-md-12">
                  
				  <input type="text" name="subject" placeholder="Subject" class="form-control" 
                                <?php if((isset($success))&&($success==0)){ print " value=\"$_REQUEST[subject]\" "; } ?> required >
                </div>

                <div class="col-md-12">
                  <!--<textarea class="form-control" name="message" rows="6" placeholder="Message" required=""></textarea>-->
				  <textarea name="message"  class="form-control" placeholder="Leave a message here" id="message" style="height: 160px"><?php if((isset($success))&&($success==0)){ print $_REQUEST['message']; } ?></textarea>
                </div>
				
				

                <div class="col-md-12 text-center">
					<p><br /><img src="captcha.php?rand=<?php echo rand(); ?>" id='captcha_image'></p>
									<p>Can't read the image? <a href='javascript: refreshCaptcha();'>click here</a> to refresh</p>

									<input type="hidden" name="acivate" value="acivate">
									
                                  
                                        <input type="text" name="captcha" placeholder="Enter Captcha *"  class="form-control"  required />
                                        <label for="subject">Enter Captcha *</label>
					<br/><br/>
                 
				 
				  <input type="submit" class="btn btn-dark" value="Send Message">
                </div>

              </div>
            </form>
          </div><!-- End Contact Form -->
		  
		  <script>
						//Refresh Captcha
						function refreshCaptcha(){
							var img = document.images['captcha_image'];
							img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
						}
						</script>

        </div>

      </div>

    </section><!-- /Contact Section -->

  </main>

<?php include('_footer.php'); ?>