Initial commit
This commit is contained in:
51
index.php
Normal file
51
index.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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>
|
||||
Reference in New Issue
Block a user