PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
if ($name != " " && $familyname != " " && $user != " " && $email != " " && $password != " ");
{
echo "The if statement evaluated to true";
} else {
echo "The if statement evaluated to false";
}
i'm trying to prevent empty posted forms by looking if their are filling something. but it doesn't works. nee help
and if someone knows how to say that you must fill in at least x characters and at least filling an "@" in the email form. thank you
Last edited by Benjamin on Sat May 16, 2009 1:04 pm, edited 1 time in total.
Reason:Added [code=php] tags.
Shouldn't be a semi-colon after the if()
" " isn't empty, it contains a single space
Consider using trim to clear any number of leading or trailing spaces from a value
You are checking if the variables are not a single space... and if I don't fill the field, you will receive "", not " "
You can use strlen() function to ensure that the field have at least x characters, and ereg / preg to check the e-mail format. Additionally, as of PHP 5.2 you can check the e-mail with filter_var($variable, FILTER_VALIDATE_EMAIL)