I am developing an application using PHP. And I have an HTML form with three input fields: username, password and confirm password. I want to prevent empty inputs. I have this PHP code for that:
if (empty($firstname)) {
$message = "Please enter first name";
}
if (empty($password)) {
$message = "Please enter password";
}
if (empty($confirm_password)) {
$message = "Please confirm password";
}
Now what it does is that it check for all 3 inputs at once and displays 3 messages. But I want it to check if first name is empty first. And if empty displays the message and exit (terminates the rest of the code, not only within the IF statement but the whole PHPcode. And if not empty then that is when it supposed to jump to the next field which is password in this case.
Please help me to achieve that.
exit();ordie();(alias to exit). You can pass a string as an argument if you want a message displayed on the pagereturn $messagein eachifcondition. That would break and would return one message at a time.exit;