Hi!
The problem with the login is that it’s possible to login also if the user enters a wrong password. Here’s the code:
<?php
if('POST' === $_SERVER['REQUEST_METHOD']){
if(false === empty($_POST['username']) && false === empty($_POST['password'])){
$conn = mysqli_connect('localhost', 'root', 'root', 'database_name');
if(!$conn){
echo 'Database Error: ' . mysqli_connect_error() ;
exit;
}
$sql = sprintf(
"SELECT username FROM utenti WHERE username = '%s' AND password = '%s' LIMIT 1",
mysqli_real_escape_string($conn, $_POST['username']),
mysqli_real_escape_string($conn, $_POST['password'])
);
$result = mysqli_query($conn, $sql);
$username = $_POST['username'];
/*if(mysqli_num_rows($result) != 0){
session_start();
$_SESSION['is_authorised'] = true;
header('Location: indexcopia.php');
exit;
}*/
}
}
?>
Thank you very much in advance!