<?php include 'includes/header.php';?>
<script type="text/javascript" src="js/sweetalert2.all.min.js"></script>
<title><?=$seo['contact_title'];?></title>
<meta name="description" content="<?=$seo['contact_description'];?>">
<meta name="keywords" content="<?=$seo['contact_keywords'];?>">
<meta name="author" content="ParsTech">
<?php
if ($_POST) {  
	if($_SESSION['captcha']==$_POST['deger']){


		$name_surname = $_POST['name_surname'];
		$email = $_POST['email'];
		$phone = $_POST['phone'];
		$title = $_POST['title'];
		$description = $_POST['description'];

		if ($name_surname <> "" && $email <> "" && $phone <> "" && $title <> "" && $description <> "" ) {

			$satir = [
				'name_surname' => $name_surname,
				'email' => $email,
				'phone' => $phone,
				'title' => $title,
				'description' => $description,
			];

			$sql = "INSERT INTO contact SET name_surname=:name_surname, email=:email, phone=:phone, title=:title, description=:description;";
			$durum = $dbh->prepare($sql)->execute($satir);
			if ($durum) {
				$sonId = $dbh->lastInsertId();
				echo '<script>Swal.fire("' . $dil['149'] . '", "' . $dil['150'] . '", "success"); </script> ';
			}
		}
	}else{
		echo '<script>Swal.fire("Hata", "Güvenlik kodu Hatalı", "error"); </script> ';

	}

}
?>
<body class="mobile_panel black_theme">
	<!-- Sepet_Urunler_Wrapper -->
	<div class="cart_product_wrapper">
		<div class="container">
			<h2 class="cart_product_list flex justify-start items-start text-center flex-col pt-8">
				<div class="product_detail_title "><?php echo $dil['037'];?></div>
				<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" class="w-full mb-4">
					<div class="form-group flex flex-col justify-start w-full mb-4">
						<label class="text-left mb-1 font-semibold standart_label" for="adisoyadi"><?php echo $dil['026'];?>*</label>
						<input type="text" name="name_surname" value="<?=$_POST['name_surname']?>" placeholder="<?php echo $dil['026'];?>" id="adisoyadi" value="" class="form_input required w-full text-sm py-2  pl-2 rounded-lg" required="">
					</div>
					<div class="form-group flex flex-col justify-start w-full mb-4">
						<label class="text-left mb-1 font-semibold standart_label" for="eposta"><?php echo $dil['031'];?>*</label>
						<input type="email" name="email" value="<?=$_POST['email']?>" placeholder="<?php echo $dil['031'];?>" id="eposta" value="" class="form_input required w-full text-sm py-2  pl-2 rounded-lg" required="">
					</div>
					<div class="form-group flex flex-col justify-start w-full mb-4">
						<label class="text-left mb-1 font-semibold standart_label" for="telefon"><?php echo $dil['040'];?>*</label>
						<input type="text" name="phone" value="<?=$_POST['phone']?>" placeholder="<?php echo $dil['040'];?>" id="telefon" value="" class="form_input required w-full text-sm py-2  pl-2 rounded-lg" required="">
					</div>
					<div class="form-group flex flex-col justify-start w-full mb-4">
						<label class="text-left mb-1 font-semibold standart_label" for="telefon"><?php echo $dil['041'];?>*</label>
						<input type="text" name="title" value="<?=$_POST['title']?>" placeholder="<?php echo $dil['041'];?>" id="title" value="" class="form_input required w-full text-sm py-2  pl-2 rounded-lg" required="">
					</div>
					<div class="form-group flex flex-col justify-start w-full mb-4">
						<label class="text-left mb-1 font-semibold standart_label" for="telefon"><?php echo $dil['042'];?>*</label>
						<textarea type="text" name="description" placeholder="<?php echo $dil['042'];?>" id="telefon" value="" class="form_input required w-full text-sm py-2  pl-2 rounded-lg" required=""><?=$_POST['description']?></textarea>
					</div>
					<center>
						<img src="captcha.php" id="capt"><br>
						<input type=button onClick=reload();  value='Yenile'>
					</center>
					<div class="form-group flex flex-col justify-start w-full mb-4">
						<label class="text-left mb-1 font-semibold standart_label" for="telefon">Güvenlik Kodu*</label>
						<input type="text" class="form_input required w-full text-sm py-2  pl-2 rounded-lg" name="deger" value="<?=$_POST['deger']?>" required="">
						<?php
						session_start();
						if (isset($_POST['deger']))
							if ($_POST['deger'] == $_SESSION['captcha'])
								echo '<span style="color:green">BAŞARILI</span>';
							else
								echo '<span style="color:red">CAPTCHA BAŞARISIZ!!!</span>';
							?>
						</div>



						<button type="submit"  class=" btn btn-lg btn-primary  btn-block"><?php echo $dil['028'];?> <span class="ml-2 icon arrow_right"></span></button>
					</form>
					<h2 class="standart_label font-medium mb-2"><center><?php echo $dil['043'];?></center></h2>
					<iframe src="<?=$ayar['maps_link'];?>" width="100%" height="200" frameborder="0" style="border:0"></iframe>
					<div class="flex flex-col justify-start items-start mt-4 pb-6"> 
						<label class="standart_label text-left mb-1 font-semibold" for="mailadresi"><?php echo $dil['044'];?>: <a href="mailto:<?=$ayar['email'];?>" class="font-normal"><?=$ayar['email'];?></a></label>
						<label class="standart_label text-left mb-1 font-semibold" for="telno"><?php echo $dil['045'];?>: <a href="tel:+<?=$ayar['phone'];?>" class="font-normal"><?=$ayar['phone'];?></a></label>
						<label class="standart_label text-left mb-1 font-semibold" for="telno"><?php echo $dil['046'];?>: <a href="tel:+<?=$ayar['business_phone'];?>" class="font-normal"><?=$ayar['business_phone'];?></a></label>
						<label class="standart_label text-left mb-1 font-semibold" for="adres"><?php echo $dil['047'];?>: <span class="font-normal"><?=$ayar['adress'];?></span></label>

					</div>


				</div>

			</div>
			<script type="text/javascript">
				function reload() {
					img = document.getElementById("capt");
					img.src = "captcha.php"
				}
			</script>
			<?php include 'includes/modal.php';?>
			<?php include 'includes/footer.php';?>