Login and Auth

This commit is contained in:
Hickmeister
2025-01-04 02:05:59 +00:00
parent b1be0cb849
commit d204dd2b99
8 changed files with 577 additions and 1807 deletions

21
assets/php/login.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
session_start();
require 'db.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = htmlspecialchars($_POST['username']);
$password = $_POST['password'];
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $user['username'];
echo 'success';
} else {
echo 'Invalid login credentials';
}
}
?>