<?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>Kayıt Ol</h2>
        <ol>
          <li><a href="index.php">Ana Sayfa</a></li>
          <li>Kayıt Ol</li>
        </ol>
      </div>
    </div>
  </section>
  <section>
    <div class="col-3 offset-md-4" style="width:300px; margin:0 auto;">
      <p class="text-center">Kayıt Ol</p>
         <form method="post">
          <div class="row my-3">
            <div class="col">
              <input name="ad" type="text" class="form-control" placeholder="Adınız">
            </div>
            <div class="col">
              <input name="soyad" type="text" class="form-control" placeholder="Soyadınız">
            </div>
          </div>
          <div class="row">
            <div class="col">
              <input name="email" type="text" class="form-control" placeholder="E-Mail Adresiniz">
            </div>
            <div class="col">
              <input name="dtarih" type="date" class="form-control" value="2000-01-01">
            </div>
          </div>
          <div class="col my-3">
            <input name="sifre" type="password" class="form-control" placeholder="Şifreniz">
          </div>
          <center><button type="submit" class="btn btn-primary my-1">Kayıt Ol</button></center><br><br><br><br><br>
        </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 = $_POST["ad"];
$soyad = $_POST["soyad"];
$email = $_POST["email"];
$sifre = md5(md5(md5(hash('sha512',md5(md5(md5($_POST["sifre"])))))));
$dtarih = $_POST["dtarih"];

$sor = mysqli_query($db, "SELECT * FROM uyeler WHERE email = '$email'");
$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 uyeler(ad,soyad,email,sifre,dtarih)VALUES('$ad','$soyad','$email','$sifre','$dtarih')");
if($kayit){
  echo '<script>swal("Başarılı", "Kayıt Başarılı Giriş Bölümüne Yönlendiriliyorsunuz.", "success");</script>';
  header("Refresh:3;url=giris.php");
}else{
  echo '<script>swal("Hata!", "Kayıt Yapılamadı Lütfen Tekrar Deneyin", "error");</script>';
  header("Refresh:3;url=kayitol.php");
}
}
}
 ?>
<?php require 'footer.php'; ?>
