I’ve got a for that (among other things) has an input field:
<input type="text" id="NumAthletes_Ratings" name="NumAthletes_Ratings" />
In my PHP code, I’d like to check if the user has entered no value or a 0. However, this code
if (isset($_POST['NumAthletes_Ratings'])) {
if ($_POST['NumAthletes_Ratings'] > 0) {
echo 'POST Parameter is set to ' . $_POST['NumAthletes_Ratings'];
} else {
echo 'POST Parameter is set to Zero';
}
} else {
echo 'POST Parameter is not set';
}
prints POST Parameter is set to Zero regardless of an empty value or 0 being passed. How can I differentiate between those cases?
You could check for the string
"0"(all$_POSTvariables are strings or arrays of strings):