dimanche 1 septembre 2019

Get checked or not checked multi value checkbox

Hi everyone I have a form with 5 checkboxes, once I run the post I would like to have all the checkboxes with the current status.

Example:

checkbox 1: on checkbox 2: off checbox 3: on checkbox 4: off checkbox 5: off

This is my code but it doesn't work with non-on states

    <?php

    if(isset($_POST['submit'])){
            $array = $_POST["check_list"];
    }

    ?>

    <form action="" method="post">
            <input type="checkbox" name="check_list[]"><label>Mon</label>
            <input type="checkbox" name="check_list[]"><label>Tue</label>
            <input type="checkbox" name="check_list[]"><label>Wed</label>
            <input type="checkbox" name="check_list[]"><label>Thu</label>
            <input type="checkbox" name="check_list[]"><label>Fri</label>
            <input type="submit" name="submit" Value="Submit"/>
    </form>

How can I get all the checkboxes with the statuses sent in the post? Thank You




Aucun commentaire:

Enregistrer un commentaire