<?php 
include '../xpanel/inc/vt.php';

$id=$_POST['id'];



$adresim = $dbh -> prepare("SELECT * FROM users_adress WHERE uye=? && id = ?");
$adresim-> execute(array($_SESSION['user']->id,$id));
$adresim = $adresim->fetch(PDO::FETCH_OBJ);
//print_r($adresim);

if($id=="ekleadres"){

	?>
	<div class="form-group flex flex-col justify-start w-full">
		<label class=" text-left mb-1 font-semibold standart_label" for="telefon">Adres Başlığı </label>
		<input type="text" class="form_input required w-full text-sm py-2  pl-2 rounded-lg" placeholder="Adres Başlığı" name="adresbaslik">
	</div>

<?php } ?>



<div class="form-group flex flex-col justify-start w-full">
	<label class=" text-left mb-1 font-semibold standart_label" for="telefon">Şehir*</label>

	<select name="sehir"  id="slct" onchange="ilcegetir(this)" class="form_input required w-full text-sm py-2  pl-2 rounded-lg" required="">
		<option value="">Şehir Seçiniz</option>

		<?php 

		$sehirler = $dbh -> prepare("SELECT * FROM sehir where aktif=1 order by sehir_title");
		$sehirler-> execute(array());
		$sehirler = $sehirler->fetchAll(PDO::FETCH_OBJ);
		foreach ($sehirler as $sehir) { ?>
			<option value="<?=$sehir->sehir_key?>" <?php if($adresim->sehir==$sehir->sehir_key){echo "selected"; $sehirkey=$sehir->sehir_key;} ?>><?=$sehir->sehir_title?></option>
		<?php } ?>
	</select>
</div>

<div class="form-group flex flex-col justify-start w-full">
	<label class=" text-left mb-1 font-semibold standart_label" for="telefon">İlçe*</label>

	<select name="ilce"  id="slctilce"  onchange="mahallegetir(this)"  class="form_input required w-full text-sm py-2  pl-2 rounded-lg" required="">
		<option value="">İlçe Seçiniz</option>

		<?php 

		$ilceler = $dbh -> prepare("SELECT * FROM ilce where aktif=1 && ilce_sehirkey=? order by ilce_title");
		$ilceler-> execute(array($sehirkey));
		$ilceler = $ilceler->fetchAll(PDO::FETCH_OBJ);
		foreach ($ilceler as $ilce) { ?>
			<option value="<?=$ilce->ilce_key?> " <?php if($adresim->ilce==$ilce->ilce_key){echo "selected"; $ilcekey=$ilce->ilce_key;} ?>><?=$ilce->ilce_title?></option>
		<?php } ?>

	</select>
</div>


<div class="form-group flex flex-col justify-start w-full">
	<label class=" text-left mb-1 font-semibold standart_label" for="telefon">Mahalle Seçiniz*</label>

	<select name="mah"  id="slctmahalle" class="form_input required w-full text-sm py-2  pl-2 rounded-lg" required="">
		<option value="">Mahalle Seçiniz</option>
		<?php 
		$mahalleler = $dbh -> prepare("SELECT * FROM mahalle where aktif=1 && mahalle_ilcekey=? order by mahalle_title");
		$mahalleler-> execute(array($ilcekey));
		$mahalleler = $mahalleler->fetchAll(PDO::FETCH_OBJ);
		foreach ($mahalleler as $mahalle) { ?>
			<option value="<?=$mahalle->mahalle_key?>" <?php if($mahalle->mahalle_key==$adresim->mah){echo "selected";} ?>><?=$mahalle->mahalle_title?></option>
		<?php } ?>
	</select>
</div>

<div class="form-group flex flex-col justify-start w-full">
	<label class=" text-left mb-1 font-semibold standart_label" for="telefon">Adres*</label>
	<textarea name="adres" class="form_input required w-full text-sm py-2  pl-2 rounded-lg" placeholder="Adresiniz" required=""><?=$adresim->adress?></textarea>
</div>






