<?php
  session_start();
  $vac = "vac";
  $host = "localhost";
  $user = "vac";
  $password = "hPUf8e4karnz61bS";

  $conn = new mysqli($host,$user,$password,$vac);
  if($conn->connect_error){
      die("Verbindung fehlgeschlagen: " . $conn->connect_error);
  }
  $sql = "SELECT id FROM users WHERE user='". $_POST['user'] .
         "' AND pw='". $_POST['pw'] ."' ";
  $result = $conn->query($sql);

  if ($result->num_rows == 1) {
    $_SESSION['id'] = $result->fetch_array()['id'];
    unset ($_SESSION['status']);
    $_SESSION['user'] = $_POST['user'];
  } else {
    $_SESSION['status'] = '<div class="falsch">' .
                            '<h1>Benutzername oder Kennwort ist falsch</h1>' .
                          '</div>';
  }
  header('Location: /');
?>
