aktuelle.kurse/m133/5_Vorlagen-und-Loesungen/skeleton_2_wal/action/login.php

23 lines
616 B
PHP
Raw Normal View History

2022-03-17 11:19:26 +01:00
<?php
session_start();
require_once("../db/mysql.class.php");
if(isset($_POST['username'])){
$DB = new DBConnector();
// $username = mysqli_real_escape_string($_POST['username']);
// this fuction ist procedural and uses two parameters
$username = htmlspecialchars($_POST['username']);
$login = $DB->getLogin(utf8_decode($username));
if($login == null || mysqli_num_rows($login) > 1){
header('Location: index.php');
}
if(password_verify($_POST['password'], $login['password'])){
$_SESSION['loggedIn'] = "true";
header("Location: ../index.php");
}else{
header("Location: ../index.php");
}
}
?>