Get $_POST from multiple checkboxes

前端 未结 5 1567
醉酒成梦
醉酒成梦 2020-11-22 01:03

I have 1 form in with multiple checkboxes in it (each with the code):



        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-11-22 01:21

    you have to name your checkboxes accordingly:

    
    

    you can then access all checked checkboxes with

    // loop over checked checkboxes
    foreach($_POST['check_list'] as $checkbox) {
       // do something
    }
    

    ps. make sure to properly escape your output (htmlspecialchars())

提交回复
热议问题