B
B
bpGusar2018-03-22 17:54:24
PHP
bpGusar, 2018-03-22 17:54:24

How to send a list of selected checkboxes in mail() and not send unselected ones?

There are a lot of checkboxes with name="blabla[]", how to send in mail() only those that are selected as a ul list?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
leni_m, 2018-03-22
@bpGusar

Only checked checkboxes are sent to the server.
For example like this:

$arr = $_POST['blabla'];
if (!empty($arr)) {
$message = "<ul>";
foreach ($arr as $el) {
    $message .= "<li>".$el."</li>";
}
$message .= "</ul>";
} else {
$message = "ни один чекбокс не был выделен";
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question