Legg til login POST side

This commit is contained in:
Alex Thomassen 2019-11-14 09:10:36 +01:00
parent 5eac686194
commit fdced57e05
Signed by: Alex
GPG Key ID: 10BD786B5F6FF5DE

24
login.php Normal file
View File

@ -0,0 +1,24 @@
<?php
require 'includes/common.php';
if (isset($_SESSION['id'])) {
header('Location: ./user.php');
exit;
}
if (!isset($_POST['username'], $_POST['password'])) {
header('Location: ./');
exit;
}
$username = $_POST['username'];
$password = $_POST['password'];
$con = connect();
$getUser = mysqli_query($con, "SELECT * FROM users WHERE username='$username' AND password='$password';");
$user = mysqli_fetch_assoc($getUser);
$_SESSION['id'] = $user['id'];
header('Location: ./user.php');
exit;
?>