I'm currently creating a simple login script in PHP, and there are many conditions that must be met for a successful login. To my knowledge, there are two ways of formatting the if statements that are required.
The first way, is using nested if statements:
if ($condition1 == true) {
if ($condition2 == true) {
if ($condition3 == true) {
//Successful login
} else {
}
} else {
}
}
And the second way is using procedural if statements:
if ($condition1 != true) {
die("error");
}
if ($condition2 != true) {
die("error");
}
if ($condition3 != true) {
die("error");
}
//successful login
Which of the two methods of dealing with many conditions is considered more logical? Are there any other methods that I haven't listed here which are better, and more logical?