<?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">Yorumcu Ekleme Paneli</h5>
            <form method="post">
              <div class="row my-3">
                <div class="col">
                  <input name="ad_soyad" type="text" class="form-control" placeholder="Yorumcu Ad Soyad" required>
                </div>
                <div class="col">
                  <input name="kadi" type="text" class="form-control" placeholder="Kullanıcı Adı" required>
                </div>
              </div>
              <div class="row">
                <div class="col">
                  <input name="email" type="text" class="form-control" placeholder="E-Mail Adresiniz" required>
                </div>
                <div class="col">
                  <input name="telefon" type="text" class="form-control" placeholder="Telefon Numarası" required>
                </div>
              </div>
              <div class="col my-3">
                <input name="sifre" type="password" class="form-control" placeholder="Şifreniz" required>
              </div>
              <center><button type="submit" class="btn btn-primary my-1">Kayıt Ol</button></center>
            </form>
          </div>
        </div>
      </div>
    </div>
  </section>
</main>
<?php require 'footer.php'; ?>
<?php
if ($_POST) {
  $ad_soyad = $_POST["ad_soyad"];
  $kadi = $_POST["kadi"];
  $email = $_POST["email"];
  $telefon = $_POST["telefon"];
  $sifre = md5(md5(md5(hash('sha512',md5(md5(md5($_POST["sifre"])))))));
  $ad_url = seflink($kadi);

  $bilgisor = mysqli_query($db, "SELECT * FROM yorumcular WHERE kadi = '$kadi' OR telefon = '$telefon' OR email = '$email'");
  $bilgisay = mysqli_num_rows($bilgisor);
  if ($bilgisay > 0) {
    echo '<script>swal("Hata!", "Bu Bilgiler Sistemde Kayıtlı", "error");</script>';
  }else {
    $kayit = mysqli_query($db, "INSERT INTO yorumcular(kadi,ad_soyad,email,sifre,telefon,ad_url)VALUES('$kadi','$ad_soyad','$email','$sifre','$telefon','$ad_url')");
    if($kayit){
      echo '<script>swal("Başarılı", "Kayıt Başarılı", "success");</script>';
      header("Refresh:2;url=fekle.php");
    }else{
      echo '<script>swal("Hata!", "Kayıt Yapılamadı Lütfen Tekrar Deneyin", "error");</script>';
      header("Refresh:2;url=fekle.php");
    }
  }

}
 ?>
