// define correct login $correct_username = 'test'; $correct_password = 'test'; if($action == "login") { // proceed with verifying password if((!$username) OR (!$password)) { $error = 'Username or Password field left blank>'; } else { // does password and username match? if(($username == $correct_username) AND ($password == $correct_password)) { // this is where we escape and show content ?> Congrats you have logged in correctly! } else { $error = "Username or Password invalid"; } } } else { $error = 'Please login'; } // error should contain something, so show the login form if($error) { echo($error); ?>