vwlsupport/web/login.php
kknobloch b294ceeec8
2025-04-21 21:34:26 +02:00

61 lines
1.9 KiB
PHP

<?php
if (isset($_GET['timeout']) && $_GET['timeout'] == 1) {
echo '<div class="alert alert-warning">Ihre Sitzung ist abgelaufen. Bitte melden Sie sich erneut an.</div>';
}
session_start();
require_once '../core/Database.php';
$pdo = Database::connect();
$error = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
$stmt = $pdo->prepare("SELECT * FROM vwl_internal_user WHERE vwlusername = :username LIMIT 1");
$stmt->execute(['username' => $username]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['vwlpassword'])) {
$_SESSION['user'] = $user['vwlusername'];
header("Location: index.php");
exit;
} else {
$error = "Ungültiger Benutzername oder Passwort.";
}
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Login</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-4">
<form method="POST">
<h3 class="text-center">Login</h3>
<?php if ($error): ?>
<div class="alert alert-danger"><?= $error ?></div>
<?php endif; ?>
<div class="mb-3">
<label class="form-label">Benutzername</label>
<input type="text" name="username" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label">Passwort</label>
<input type="password" name="password" class="form-control" required>
</div>
<button class="btn btn-primary w-100" type="submit">Einloggen</button>
</form>
</div>
</div>
</div>
</body>
</html>