I am writing a code in which the user is asked for username and password. If the details provided match the details in the database, then he is displayed the data, else he is prompted with a message that the information provided is not valid.
Here is the part of the code that says information is not valid,
<?php if($user!=$username && $pass!=$password)
{
?>
<p id="intro">Invalid Information</p>
<?php
}
?>
But the problem I am facing is that even if the username and password does not match, the message Invalid Information is not displayed. Please help out. Thanks
You need OR, not AND:
P.S. I used the alternative syntax. It looks better.
The reasoning for using OR and not AND, if you check for AND, only if both username AND password is wrong, the condition will evaluate to true (if one of them is correct, you will get FALSE).