Legg til login POST side
This commit is contained in:
parent
5eac686194
commit
fdced57e05
24
login.php
Normal file
24
login.php
Normal 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;
|
||||
?>
|
Loading…
Reference in New Issue
Block a user