POST Request for Checkbox

How to get a value via post from flags ???

For example

    <input type="checkbox" name="" value="a1" checked><br>
     <input type="checkbox" name="" value="a2"> <br>
     <input type="checkbox" name="" value="a3"> <br> 
     <input type="checkbox" name="" value="a4"> <br> 
     <input type="submit" value=""></p>

Well, how to get the value it is necessary to prescribe each option here so

       $name = $_POST[''];
         $name = $_POST[''];
        $name = $_POST[''];

and what will be going to $ name?


Answer 1

I understand the flag you called Checkbox.

Getting the value – as well as any other field, no different.

p.s. We need different names from Checkbox to do

UPD:

<input type="checkbox" name="name[]" value="" checked><br>
 <input type="checkbox" name="name[]" value=""> <br>
 <input type="checkbox" name="name[]" value=""> <br> 
 <input type="checkbox" name="name[]" value=""> <br>

That’s what you get:

print_r( $_POST['name'] );

Specific implementation depends on what you need …


Answer 2

If you need to choose several flags, you still need to enter an array in NAME = “”.
For example name = “Country” you need Name = “Country [].”

You can still:

<input type="checkbox" name="name[]" value=""><br>
     <input type="checkbox" name="name[]" value=""> <br>
     <input type="checkbox" name="name[]" value=""> <br> 
     <input type="checkbox" name="name[]" value=""> <br> 
     <input type="submit" value="">
$joined_name = join(", ", $_POST['name']);
echo "$joined_name";

In this case, the names will be displayed through the comma.