samedi 18 mars 2017

HTML form not passing checkbox value trough $_POST in php file

i have a form in HTML with some checkboxes and i want to send an email with the selected checboxes in the body, the problem is that the "text" fields are passing to the PHP variables, but the checkboxes values are always set to uncheck when i test it on the PHP file:

HTML:

<div class="col-md-6">
<div class="c-checkbox-list">
<div class="c-checkbox">
<input type="checkbox"   name="checkbox1citadina" id="checkbox1citadina" value="checkbox1citadina" class="form-control c-check" >
<label for="checkbox1citadina">
<span></span>
<span class="check"></span>
<span class="box"></span> Citadina</label>
</div>

PHP:

$reservas_bicicletas = ''; 

if (isset($_POST['checkbox1citadina'])) {
    $reservas_bicicletas .= "Citadina: checked\n";
} else {
    $reservas_bicicletas .= "Citadina: unchecked\n";
}

echo $reservas_bicicletas;

$reservas_bicicletas always retrieves the else value.

Need help guys, thanks in advance,




Aucun commentaire:

Enregistrer un commentaire