<?php require 'ust.php'; ?>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<main id="main">
  <section class="breadcrumbs">
    <div class="container">
      <div class="d-flex justify-content-between align-items-center">
        <h2>Yorumcu Kayıt Ol</h2>
        <ol>
          <li><a href="index.php">Ana Sayfa</a></li>
          <li>Yorumcu Kayıt Ol</li>
        </ol>
      </div>
    </div>
  </section>
  <section>
    <div class="col-3 offset-md-4">
      <p class="text-center">Yorumcu Kayıt Ol</p>
        <form method="post">
          <div class="col my-3">
            <label>Ad Soyad</label>
            <input name="ad_soyad" type="text" class="form-control" required>
          </div>
          <div class="col my-3">
            <label>Kullanıcı Adı</label>
            <input name="kadi" type="text" class="form-control" required>
          </div>
          <div class="col my-3">
            <label> E-Posta Adresiniz </label>
            <input name="email" type="email" class="form-control" required>
          </div>
          <div class="col my-3">
            <label> Telefon Numaranız </label>
            <input name="telefon" type="text" class="form-control" required>
          </div>
          <div class="col my-3">
            <label> Şifreniz </label>
            <input name="sifre" type="password" class="form-control" required>
          </div>
          <center><button type="submit" class="btn btn-primary my-1">Kayıt Ol</button></center>
        </form>
      </div>
    </div>
  </section>
</main>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<?php
if($_POST){
$ad_soyad = $_POST["ad_soyad"];
$email = $_POST["email"];
$telefon = $_POST["telefon"];
$kadi = $_POST["kadi"];
$sifre = md5(md5(md5(hash('sha512',md5(md5(md5($_POST["sifre"])))))));
$ad_url = seflink($kadi);
$sor = mysqli_query($db, "SELECT * FROM yorumcular WHERE email = '$email' OR kadi = '$kadi'");
$say = mysqli_num_rows($sor);

if($say > 0){
echo '<script>swal("Hata!", "Bu Bilgiler Sistemimizde 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ı Giriş Bölümüne Yönlendiriliyorsunuz.", "success");</script>';
  header("Refresh:2;url=ygiris.php");
}else{
  echo '<script>swal("Hata!", "Kayıt Yapılamadı Lütfen Tekrar Deneyin", "error");</script>';
  header("Refresh:2;url=ykayitol.php");
}
}
}
 ?>
<?php require 'footer.php'; ?>
