Skip to content
Advertisement

Trying to access array offset on value of type null…in login details

if ($row['email'] == $email && $row['password'] == $password) { 
  echo "Login success Welcome".$row['username']; # code... 
} 
else{ 
  echo "failed to login"; 
}

Advertisement

Answer

You can check if(!is_null($row)) along with the other checks, or simply:

if( $row && $row['email']==$email && $row['password']==$password ) { ... };

This happens when you query your DB, and there is no match, so there’s no result, so the result is empty/null.. which you seem not to be checking within your code..

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement