PHP can I combine these if statements.

Associate
Joined
11 Oct 2008
Posts
268
Hey guys, I have cobbled together a little bit of code to display an error message if a submitted username or passwords is wrong. At the moment I have to do the logic for the user names and password seperatly or it will not work.

Is there anyway to combine the 2 if/elseif statements?

PHP:
if ((isset($_POST['username'])) && ($username !== $db_username)) {     

    $loginmsg ="Username/password is wrong";

    } 
    elseif ((isset($_POST['password'])) && ($password !== $db_password)) {     

    $loginmsg ="Username/password is wrong";
    }
 
Back
Top Bottom