Is the following code vulnerable to Sql injections and how to validate it ?
$query=("select * from table2 where username = '$username'and password='$password'");
$result=  mysqli_query($connect, $query);
       $row=  mysqli_fetch_assoc($result);
    if  ($username==$row['username']&&$password==$row['password'])
    {
        header('location:header.php');//to go header
        }
else
{
    header('location:insert_p.php');}
 
     
    