Reputation: 95
Im doing a page that contains an input that should contains 0 or 1
I did the condition to stop if the field is empty... I need a way to make a second condition that the variable added is "1" or "0" only.
if(empty($moviedisplay)){
echo "Movie display is a must";
}
Upvotes: 0
Views: 61
Reputation: 318488
if(empty($moviedisplay) || ($moviedisplay != 0 && $moviedisplay != 1)) {
echo "Movie display is a must";
}
If you prefer different messages:
if(empty($moviedisplay)) {
echo "Movie display is a must";
}
elseif($moviedisplay != 0 && $moviedisplay != 1) {
echo "Movie display must be 0 or 1";
}
Besides that, please read the PHP docs - this is an extremely basic question you shouldn't have to ask here or on any other site.
Upvotes: 1