<?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">SMTP (Mail Server) Ayarları Düzenleme Paneli</h5>
            <?php $bilgigetir = mysqli_fetch_array(mysqli_query($db, "SELECT * FROM site_smtp WHERE id = '1'")); ?>
            <form method="post">
              <div class="row my-3">
                <div class="col">
                  <input name="smtp_host" type="text" class="form-control" placeholder="SMTP_Host" value="<?php echo $bilgigetir["smtp_host"]; ?>" required>
                </div>
                <div class="col">
                  <input name="smtp_port" type="text" class="form-control" placeholder="SMTP_Port" value="<?php echo $bilgigetir["smtp_port"]; ?>" required>
                </div>
              </div>
              <div class="row">
                <div class="col">
                  <input name="smtp_gvnlk" type="text" class="form-control" value="<?php echo $bilgigetir["smtp_gvnlk"]; ?>" placeholder="Güvenli Bağlantı İçin SSL Normal Bağlantı İçin TLS" required>
                </div>
                <div class="col">
                  <input name="smtp_mail" type="text" class="form-control" value="<?php echo $bilgigetir["smtp_mail"]; ?>" placeholder="Mail Adresiniz" required>
                </div>
              </div>
              <div class="col my-3">
                <input name="smtp_sifre" type="password" class="form-control" value="<?php echo $bilgigetir["smtp_sifre"]; ?>" placeholder="Mail Şifreniz" required>
              </div>
              <center><button type="submit" class="btn btn-primary my-1"> Güncelle </button></center>
            </form>
          </div>
        </div>
      </div>
    </div>
  </section>
</main>
<?php require 'footer.php'; ?>
<?php
if ($_POST) {
  $smtp_host = $_POST["smtp_host"];
  $smtp_port = $_POST["smtp_port"];
  $smtp_gvnlk = $_POST["smtp_gvnlk"];
  $smtp_mail = $_POST["smtp_mail"];
  $smtp_sifre = $_POST["smtp_sifre"];

    $kayit = mysqli_query($db, "UPDATE site_smtp SET smtp_host = '$smtp_host', smtp_port = '$smtp_port', smtp_gvnlk = '$smtp_gvnlk', smtp_mail = '$smtp_mail', smtp_sifre = '$smtp_sifre' WHERE id = '1'");
    if($kayit){
      echo '<script>swal("Başarılı", " Bilgiler Başarılı bir Şekilde Güncellendi ", "success");</script>';
      header("Refresh:2;url=smtpayar.php");
    }else{
      echo '<script>swal("Hata!", "Güncelleme Yapılamadı Lütfen Tekrar Deneyin", "error");</script>';
      header("Refresh:2;url=smtpayar.php");
    }
}
 ?>
