So I'm nesting if statements within another to use it for form validation, unfortunately its not working. Say I use an invalid email it just goes to a blank page, which is telling me that its not reading through it. Here's what my code looks like
// Verification
if (empty($name && $username && $email && $pass1 && $pass2))
{
echo "Complete all fields";
// Password match
if ($pass1 <> $pass2)
{
echo $passmatch = "Passwords don't match";
// Email validation
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
echo $emailvalid = "Enter a valid email";
// Password length
if (strlen($pass1) <= 6)
{
echo $passlength = "Password must be at least 6 characters long";
// Password numbers
if (!preg_match("#[0-9]+#", $pass1))
{
echo $passnum = "Password must include at least one number!";
// Password letters
if (!preg_match("#[a-zA-Z]+#", $pass1))
{
echo $passletter = "Password must include at least one letter!";
}
}
}
}
}
}
Sorry that the code is a bit messy I'm still working on it. Thanks in advance.