Need help understanding how these nested PHP "if" and "else" statements relate to one another.
The following code works, but I'd like to improve my understanding of the if and else statements. How do the first and second else statement know which if they're related to?
Does the first else statement pertain to the if statement directly above it? I know the second else statement relates to the very first IF statement but I don't understand why it's not relating to any of the other IF statements instead?
Second IF checks if the passwords match. It then has a further IF to check if the password is empty (if so give a different error message)
If the form has been submitted and the passwords match and the passwords are not empty then add to database.
Open in new window