<?php require 'ust.php'; ?>
<main id="main" class="main">
  <section class="section dashboard">
    <div class="row">
      <div class="col-12">
        <div class="card">
          <div class="card-body">
            <h5 class="card-title">Site Ayarları Düzenleme Paneli</h5>
            <?php $bilgigetir = mysqli_fetch_array(mysqli_query($db, "SELECT * FROM site_ayar WHERE id = '1'")); ?>
            <form method="post">
              <div class="row my-3">
                <div class="col">
                  <label> Site Adı </label>
                  <input name="site_adi" type="text" class="form-control"  value="<?php echo $bilgigetir["site_adi"]; ?>" required>
                </div>
                <div class="col">
                  <label> Site URL (Sonuna / SLASH Koymayın) </label>
                  <input name="site_url" type="text" class="form-control" value="<?php echo $bilgigetir["site_url"]; ?>" required>
                </div>
              </div>
              <div class="row my-3">
                <div class="col">
                  <label> Site Başlık TİTLE </label>
                  <input name="site_baslik" type="text" class="form-control" value="<?php echo $bilgigetir["site_baslik"]; ?>" required>
                </div>
                <div class="col">
                  <label> Site Anahtar Kelimeler </label>
                  <input name="site_key" type="text" class="form-control" value="<?php echo $bilgigetir["site_key"]; ?>" required>
                </div>
              </div>
              <div class="row my-3">
                <div class="col">
                  <label> Site Açıklama </label>
                  <input name="site_aciklama" type="text" class="form-control" value="<?php echo $bilgigetir["site_aciklama"]; ?>" required>
                </div>
                <div class="col">
                  <label>Falcı Komisyon Oranı (%) </label>
                  <input name="komisyon" type="text" class="form-control" value="<?php echo $bilgigetir["komisyon"]; ?>" required>
                </div>
              </div>
              <div class="col my-3">
                <label> Site Footer </label>
                <input name="footer" type="text" class="form-control" value="<?php echo $bilgigetir["footer"]; ?>"  required>
              </div>
              <div class="form-group my-3">
                <label> Google Analytics </label>
                <textarea name="googlekod" class="form-control" id="exampleFormControlTextarea1" rows="3"><?php echo $bilgigetir["googlekod"]; ?></textarea>
              </div>
              <center><button name="site_ayar" type="submit" class="btn btn-primary my-3"> Güncelle </button></center>
            </form>
          </div>
        </div>
      </div>
    </div>
  </section>
</main>
<?php require 'footer.php'; ?>
<?php
if (isset($_POST["site_ayar"])) {
  $site_adi = $_POST["site_adi"];
  $site_url = $_POST["site_url"];
  $site_baslik = $_POST["site_baslik"];
  $site_key = $_POST["site_key"];
  $site_aciklama = $_POST["site_aciklama"];
  $komisyon = $_POST["komisyon"];
  $footer = $_POST["footer"];
  $googlekod = $_POST["googlekod"];
  $duzenle = mysqli_query($db, "UPDATE site_ayar SET site_adi = '$site_adi', site_url = '$site_url', site_baslik = '$site_baslik', site_key = '$site_key', site_aciklama = '$site_aciklama', komisyon = '$komisyon', footer = '$footer', googlekod = '$googlekod' WHERE id = '1'");
  if ($duzenle) {
    echo '<script>swal("Başarılı", "Bilgiler Başarılı Bir Şekilde Düzenlendi", "success");setTimeout(function(){ window.location.assign("ayarlar.php");}, 1500);</script>';
  }else {
    echo '<script>swal("Hata", "Beklenemdik Bir Hata Meydana Geldi Lütfen Tekrar Deneyin.", "error");</script>';
  }
}
 ?>
