<?php
  session_start();
  require_once('connectscr.php');

  $username = $_POST['username'];
  $password = sha1($_POST['pwd']);

  $usercheck = "SELECT * FROM users WHERE username='$username'";
  $dbconnect->real_escape_string($usercheck);
  $query = mysqli_query($dbconnect, $usercheck);
  $fetch = mysqli_fetch_object($query);

  if($fetch->username == $username && $fetch->password == $password)
  {
    header('Location: backend.php');
  }
  else
  {
    echo '<script> alert("Zugriff verweigert! Benutzername und/oder Passwort falsch."); window.location.href="login.php";</script>';
  }
?>
