I am having a form with name, radios and email.
<form action="index.php" method="POST" role="form">
<input class="form-control" name="name" type="text" placeholder="NAME">
<input class="form-control" name="email" type="text" placeholder="EMAIL(optional)">
<input type="radio" class="form-check-input" name="gender" value="male">Male
<input type="radio" class="form-check-input" name="gender" value="female">Female
<input type="radio" class="form-check-input" name="gender" value="other">Other
...
To test whether name, email or radios are filled in, i use isset
if (isset($_POST['name'])) {
echo 'name isset';
}
if (isset($_POST['email'])) {
echo 'email isset';
}
if (isset($_POST['gender'])) {
echo 'gender isset';
}
What i don't understand: even when i leave the fields empty, it outputs the 2 echo's from the name
and email
loop, but NOT the gender
loop.
Can someone explain me why the return values of name and email are TRUE even when i leave the fields empty and submit?
And why, if i do not click any of the radios, this return value is FALSE? ( echo 'gender isset';
is not outputted!)