Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
checkbox.php
<!DOCTYPE html>
<html>
<body>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') :
if (!isset($_POST['tarefas'])) {
echo'Nenhuma tarefa feita.';
} else {
echo 'Tarefas feitas:';
echo '<ul>';
foreach ($_POST['tarefas'] as $tarefa) {
echo '<li>' . $tarefa . '</li>';
}
echo '</ul>';
}
else :
?>
<form action="" method="post">
<input type="checkbox" name="tarefas[]" value="Caminhar">Caminhar<br>
<input type="checkbox" name="tarefas[]" value="Ir ao banco">Ir ao banco<br>
<input type="checkbox" name="tarefas[]" value="Ligar para escola">Ligar para escola<br>
<input type="checkbox" name="tarefas[]" value="Cancelar TV a cabo">Cancelar TV a cabo
<br>
<input type="submit">
</form>
<?php
endif;
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.