Login doesn't work (anymore)

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!

You commented out the part where you check if the user/pw exists.
I don’t know how you check if someone has logged in?

I wonder how I couldn’t see that lol xD