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

// Stop making changes below this line
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'phpmailer/PHPMailer-master/src/Exception.php';
require 'phpmailer/PHPMailer-master/src/PHPMailer.php';
require 'phpmailer/PHPMailer-master/src/SMTP.php';
?>

<?php
if(isset($_POST['send']))
{	
	if($_POST['act_answer'] == $_POST['answer'])
	{
	    //SEND EMAIL TO ADMINISTRATOR
        $name = 'Properti Dost';
        $email = $contact_email;

		$email_account = "info@prismonline.in";
        $email_password = "~I5er1FU&bR0";

		// Recipient
		$mail = new PHPMailer;
		$mail->isSMTP();
		$mail->SMTPDebug = 0;

		$subject="A New Enquiry Posted";
		$message= '<table border="0" width="100%" cellspacing="2" cellpadding="2" align="center">
				<tr>
					<td colspan="2">A new enquiry has been posted. Details are below,</td>
				</tr>
				<tr>
					<td colspan="2">&nbsp;</td>
				</tr>
				<tr>
					<td width="30%">Name : </td>
					<td width="70%">'.stripslashes($_POST['contact_name']).'</td>
				</tr>
				<tr>
					<td>Phone No : </td>
					<td>'.stripslashes($_POST['contact_phone']).'</td>
				</tr>
				<tr>
					<td>Email Address : </td>
					<td>'.stripslashes($_POST['contact_email']).'</td>
				</tr>
				<tr>
					<td valign="top">Message : </td>
					<td>'.nl2br(stripslashes($_POST['contact_message'])).'</td>
				</tr>
				</table>';
				
		$mail->Host = 'mail.prismonline.in';
		$mail->Port = 587;
		$mail->SMTPAuth = true;
		$mail->SMTPSecure = "tls";
		$mail->Username = $email_account;
		$mail->Password = $email_password;

		$mail->setFrom('info@prismonline.in', "Properti Dost");
		$mail->addReplyTo('info@prismonline.in', "");
		$mail->addAddress($email);
		$mail->Subject = $subject;
		$TemplateMessage = $message;
		$mail->MsgHTML($TemplateMessage);
		$mail->send();
       // echo 'Message has been sent successfully';
       
        unset($_SESSION['CONTACT_NAME']);
        unset($_SESSION['CONTACT_EMAIL']);
        unset($_SESSION['CONTACT_PHONE']);
        unset($_SESSION['CONTACT_MESSAGE']);
       
		$_SESSION['msg_succ'] = 'Thank you. Your message has been successfully sent to administrator.';
		header("location: contact-us.php");
		exit;
	} 
    else
    {
        $_SESSION['CONTACT_NAME'] = $_POST['contact_name'];
        $_SESSION['CONTACT_EMAIL'] = $_POST['contact_email'];
        $_SESSION['CONTACT_PHONE'] = $_POST['contact_phone'];
        $_SESSION['CONTACT_MESSAGE'] = $_POST['contact_message'];
        
        $_SESSION['msg_fail'] = 'Your answer is incorrect. Please try again!';
    	header("location: contact-us.php");
    	exit;
    }
}

$a= rand(0,99);
$b = rand(0,99);
$c = $a+$b;
?>

			<script language="javascript" type="text/javascript">
			function echeck(str) 
			{
					var at="@"
					var dot="."
					var lat=str.indexOf(at)
					var lstr=str.length
					var ldot=str.indexOf(dot)
					if (str.indexOf(at)==-1){
						alert("Invalid email address");
					   return false;
					}
			
			
					if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
						alert("Invalid email address");
					   return false;
					}
			
			
					if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
						alert("Invalid email address");
						return false;
					}
			
			
					 if (str.indexOf(at,(lat+1))!=-1){
						alert("Invalid email address");
						return false;
					 }
			
			
					 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
						alert("Invalid email address");
						return false;
					 }
			
			
					 if (str.indexOf(dot,(lat+2))==-1){
						alert("Invalid email address");
						return false;
					 }
					
			
					 if (str.indexOf(" ")!=-1){
						alert("Invalid email address");
						return false;
					 }
					 return true;					
			}
			
			function form_validation()
			{
				if(document.getElementById('contact_name').value == "")
				{
					alert("Please enter name");
					document.getElementById('contact_name').focus();
					return false;
				}
				
				if(document.getElementById('contact_phone').value == "")
				{
					alert("Please enter phone no.");
					document.getElementById('contact_phone').focus();
					return false;
				}

				if(document.getElementById('contact_email').value == "")
				{
					alert("Please enter email address");
					document.getElementById('contact_email').focus();
					return false;
				}
			   
				if(echeck(document.getElementById('contact_email').value)==false){
					document.getElementById('contact_email').focus();
					return false;
				}
				
				if(document.getElementById('contact_message').value == "")
				{
					alert("Please enter message");
					document.getElementById('contact_message').focus();
					return false;
				}
				
				if(document.getElementById('answer').value == "")
				{
					alert("Please enter answer");
					document.getElementById('answer').focus();
					return false;
				}
			}
			</script>

			<!-- page template area start -->
			<div style="background-image: url('images/bg/contact.jpg'); background-size:100% 100%; padding:90px 0;" id="desktop-view">
  				<div class="">
					<div class="section-content">
						<div class="row">
							<div class="col-md-12">
								<h1 class="title text-white text-center">Contact Us</h1>
								<p class="text-white text-center"><a href="index.php">Home</a> / Contact Us</p>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div style="background-image: url('images/bg/contact.jpg'); background-size:100% 100%; padding:60px 0;" id="tab-view">
  				<div class="">
					<div class="section-content">
						<div class="row">
							<div class="col-md-12">
								<h1 class="title text-white text-center">Contact Us</h1>
								<p class="text-white text-center"><a href="index.php">Home</a> / Contact Us</p>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div style="background-image: url('images/bg/contact.jpg'); background-size:100% 100%; padding:35px 0;" id="mobile-view">
  				<div class="">
					<div class="section-content">
						<div class="row">
							<div class="col-md-12">
								<h1 class="title text-white text-center">Contact Us</h1>
								<p class="text-white text-center"><a href="index.php">Home</a> / Contact Us</p>
							</div>
						</div>
					</div>
				</div>
			</div>
			
			<section id="about">
				<div class="container mt-0 pb-0 pt-30">
					<div class="section-content">
						<div class="row">
							<div class="col-sm-4 col-md-4">
							    <div class="pt-10 pb-10 pl-20 pr-20 mb-10" style="background:#ed0d87; border-radius:10px;">
							        <div class="text-center pt-10 pb-10">
							            <div style="border:2px solid #fff; text-align:center; padding:19px; border-radius:50%; position:relative; margin:0 auto; width:97px; background:#fff;">
    							            <i class="fa fa-map-marker" style="color:#ed0d87; font-size:50px;"></i>
    							        </div>
							        </div>
    							    <h3 class="title mt-0 mb-5 text-white text-center">Our Location</h3>
    							    <div class="text-white text-center"><b>PORIBES FOUNDATION</b><br>
    							        <?php echo $contact_address;?></div>
						        </div>
						    </div>
    						<div class="col-sm-4 col-md-4">
							    <div class="pt-10 pb-10 pl-20 pr-20 mb-10" style="background:#902b8f; border-radius:10px;">
							        <div class="text-center pt-10 pb-10">
							            <div style="border:2px solid #fff; text-align:center; padding:19px; border-radius:50%; position:relative; margin:0 auto; width:97px; background:#fff;">
							                <i class="fa fa-phone" style="color:#902b8f; font-size:50px;"></i>
							            </div>
							        </div>
    							    <h3 class="title mt-0 mb-5 text-white text-center">Contact Numbers</h3>
    							    <div class="text-white text-center">
    							        <?php echo $contact_no1;?><?php if($contact_no2!="") { ?><br><?php echo $contact_no2;?><?php } ?></div>
						        </div>
						    </div>
					        <div class="col-sm-4 col-md-4">
							    <div class="pt-10 pb-10 pl-20 pr-20 mb-10" style="background:#67A341; border-radius:10px;">
							        <div class="text-center pt-10 pb-10">
							            <div style="border:2px solid #fff; text-align:center; padding:19px; border-radius:50%; position:relative; margin:0 auto; width:97px; background:#fff;">
							                <i class="fa fa-envelope" style="color:#67A341; font-size:50px;"></i>
							            </div>
							        </div>
    							    <h3 class="title mt-0 mb-5 text-white text-center">Email Address</h3>
    							    <div class="text-white text-center">
    							        <?php echo $contact_email;?><br>&nbsp;</div>
						        </div>
						    </div>
						</div>
					</div>
				</div>
			</section>
			
			<section id="about">
				<div class="container mt-0 pb-10 pt-10">
					<div class="row">
						<div class="col-md-7">
							<h1 class="title mt-0 mb-10" style="text-align:left;">Get Touch <span style="color:#ed0d87;">With Us</span></h1> 
							<p style="color:#777; text-align:left;">If you would like to get in contact with us, you have a number of options you can call or mail to below option, our team will support you as soon as possible.</p>
						    <?php if(isset($_SESSION['msg_succ'])) { ?>
							<p class="text-left"><img src="images/tick.png" alt="" /> <?php echo $_SESSION['msg_succ'];?></p>
							<?php 
							unset($_SESSION['msg_succ']);
							} 
							?>
							<?php if(isset($_SESSION['msg_fail'])) { ?>
							<p class="text-left"><img src="images/cross.png" alt="" /> <?php echo $_SESSION['msg_fail'];?></p>
							<?php 
							unset($_SESSION['msg_fail']);
							} 
							?>
							<form id="contact_form" name="contact_form" class="" action="" method="post" onSubmit="return form_validation();">
							<div class="row">
								<div class="col-sm-12">
									<div class="form-group">
										<input name="contact_name" id="contact_name" class="form-control" type="text" placeholder="Enter Name *" value="<?php //echo $_SESSION['CONTACT_NAME'];?>">
									</div>
								</div>
								<div class="col-sm-12">
									<div class="form-group">
										<input name="contact_phone" id="contact_phone" class="form-control" maxlength="10" type="text" placeholder="Enter Phone No. *" value="<?php //echo $_SESSION['CONTACT_PHONE'];?>">
									</div>
								</div>
								<div class="col-sm-12">
									<div class="form-group">
										<input name="contact_email" id="contact_email" class="form-control" type="text" placeholder="Enter Email Address *" value="<?php //echo $_SESSION['CONTACT_EMAIL'];?>">
									</div>
								</div>
							</div>
							<div class="form-group">
								<textarea name="contact_message" id="contact_message" class="form-control required" rows="5" placeholder="Enter Message *"><?php //echo stripslashes($_SESSION['CONTACT_MESSAGE']);?></textarea>
							</div>
							<div class="form-group">
							    <p><?php echo $a;?>+<?php echo $b;?> = ?</p>
								<div class="form-group">
									<input name="answer" id="answer" class="form-control" type="text" placeholder="Enter Answer *">
								</div>
							</div>
							<div class="form-group">
								<input type="hidden" name="send" id="send" value="1" />
								<input type="hidden" name="act_answer" id="act_answer" value="<?php echo $c;?>" />
								<button type="submit" class="btn btn-flat btn-theme-colored border-left-theme-color-2-4px">Send Your Message</button>
							</div>
							</form>
						</div>
						<div class="col-md-5">
							<div class="row">
                            	<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3681.821185141847!2d88.43341687530307!3d22.660454679429172!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x39f89eff5109449b%3A0xaa914b9f8ef6c0eb!2s14%2C%20Kabi%20Sukanta%20Sarani%20Rd%2C%20Khalisha%20Kota%2C%20Birati%2C%20North%20Dumdum%2C%20West%20Bengal%20700051!5e0!3m2!1sen!2sin!4v1745656876658!5m2!1sen!2sin" width="100%" height="500" style="border:0;" allowfullscreen="" loading="" referrerpolicy="no-referrer-when-downgrade"></iframe>
                            </div>
						</div>
					</div>
				</div>
			</section>
			<!-- page template area end -->

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