watch.twip-network.org/login.php
2024-01-20 16:04:27 +01:00

25 lines
671 B
PHP

<?php
session_start();
require_once 'config.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Handle login form submission
$username = $_POST['username'];
$password = $_POST['password'];
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$query = "SELECT * FROM users WHERE username = '$username' AND password = '$hashed_password'";
$result = mysqli_query($mysqli, $query);
if (mysqli_num_rows($result) == 1) {
$user = mysqli_fetch_assoc($result);
$_SESSION['user_id'] = $user['id'];
header('Location: main.php');
exit();
} else {
echo "Invalid username or password.";
}
}
?>