<?php

require_once('config.php');

if($_POST){
  $email = trim(strtolower($_POST['email']));
  $password = md5(md5(md5('viapos').md5($_POST['password'])).'furkankavlak');

  $venue = $db->query("SELECT id,email,password FROM venues WHERE email='$email' AND password='$password'")->fetch();

  if($email == $venue['email'] && $password == $venue['password']){
    
    $_SESSION["venue"] = $venue['id'];

    header("Location: licenses.php");

  } else {
    $response = "Girdiğiniz bilgiler geçersizdir.";
  }
}

?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <?php
    include('menu.php');
    ?>
    <?php
    if(isset($response))
      echo $response;
    ?>
    <form class="" method="post">
      E-mail: <input type="email" name="email"><br>
      Şifre: <input type="password" name="password"><br>
      <button type="submit" name="button">Giriş</button>
    </form>
  </body>
</html>
