Wrong error message when login even username and password is correct
<p>Whenever I try to login, the message always says <code>username or password is invalid</code> eventhough my username and password is correct.</p>

<p>here's my login php code. Also, i used password_hash on my registration.</p>

<pre><code>&lt;?php
    session_start();
    include_once 'dbcontroller.php';
    if (isset($_POST['submit'])) {
        if (empty($_POST['username']) || empty($_POST['password'])) {
        echo "&lt;script&gt;alert('Please input your username and password'); window.location='index.php';&lt;/script&gt;";
        }
        else
        {
            // Define $username and $password
            $username=$conn-&gt;real_escape_string(trim($_POST['username']));
            $password=$conn-&gt;real_escape_string(trim($_POST['password']));

            $query = $conn-&gt;query("select * from users where username='$username'");
            $row = $query-&gt;fetch_array();
            if (password_verify($password, $row['password']))
            {
                $_SESSION['login_user']=$row['username'];
                header("location: user/home.php?username=$user_check&amp;request=login&amp;status=success"); // Redirecting To Other Page
            }   
            else{
                echo "&lt;script&gt;alert('The username or password you entered is invalid.'); window.location='index.php';&lt;/script&gt;";;
            }
            $conn-&gt;close(); // Closing Connection

        }

    }
?&gt;
</code></pre>