I want to validate and execute PHP code depending on whether you click checkbox or not. In the form this this:
<input type="checkbox" name="checkbox" value="marcado">
<input type="submit" name="">
And in PHP I have:
if (!empty($_POST['checkbox'])) {
echo "MARCADO";
echo "<br/>";
echo $_POST['checkbox'];
} else {
echo "ERROR";
echo "<br/>";
echo $_POST['checkbox'];
}
But it always shows the ERROR message, whether or not you click checkbox .