Files
rfdb/index.php
2026-04-12 02:20:01 +02:00

52 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
require "db.php";
session_start();
// If already logged in redirect
if (isset($_SESSION["auth"])) {
header("Location: frequenze.php");
exit();
}
// Login request
if (isset($_POST["login"]) && isset($_POST["username"]) && isset($_POST["password"])) {
$username = $_POST["username"];
$password = $_POST["password"];
$users = db_query("SELECT id, password FROM utenti WHERE username = ?", [$username]);
if (!empty($users) && password_verify($password, $users[0]["password"])) {
$_SESSION["auth"] = $users[0]["id"];
header("Location: frequenze.php");
exit;
}
$error = "Credenziali errate!";
}
?>
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<title>RFDB - Login</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<pre>
,--..Y
\ /`. R.F.D.B. Radio Frequency Data Base
A. \ Bassano del Grappa (VI)
_/ """--'
</pre>
<?php if (isset($error)) echo "<p style=\"color:red\">$error</p>"; ?>
<form method="POST">
Username: <input type="text" name="username" required><br>
Password: <input type="password" name="password" required><br><br>
<button type="submit" name="login">Login</button>
</form>
</body>
</html>