mercredi 6 janvier 2021

How to update database using checkbox in form in php mysql

I'm new to php and html and i need some help for my project. I have seen a few examples online but i don't quite understand them. What i want to do is to update the database using a form with a checkbox. If it is checked then the database should be updated as 1. Else if it is unchecked then update it with 0. Currently, my issue is not knowing how to make it so that the code will update the database with 1 or 0 if it is checked or unchecked. I know that i have to create a separate php file to do it but i'm not sure how to do it. Below is the code i used for the form. Please help me.

<i class="icon-book text-muted"></i> &nbsp; Select modules to enroll student in:<br><br>
                                        <div class="form-group has-feedback has-feedback-left" style="padding-left:25px">       
                                            <div class="checkbox">
                                                <input type="checkbox" name="module[1]" value="1"><label>MRO</label>
                                            </div>      
                                    </div>
                                    
                                    <div class="form-group has-feedback has-feedback-left" style="padding-left:25px">   
                                            <div class="checkbox">
                                                <input type="checkbox" name="module[2]" value="1"><label>CNC</label>
                                            </div>      
                                    </div>
                                    
                                    <div class="form-group has-feedback has-feedback-left" style="padding-left:25px">   
                                            <div class="checkbox">
                                                <input type="checkbox" name="module[3]" value="1"><label>Aero-Science</label>
                                            </div>      
                                    </div>
                                    
                                    <div class="form-group has-feedback has-feedback-left" style="padding-left:25px">   
                                            <div class="checkbox">
                                                <input type="checkbox" name="module[4]" value="1"><label>Aero-Structures</label>
                                            </div>      
                                    </div>
                                    
                                    <div class="form-group has-feedback has-feedback-left" style="padding-left:25px">   
                                            <div class="checkbox">
                                                <input type="checkbox" name="module[5]" value="1"><label>Aero-Systems</label>
                                            </div>      
                                    </div>



Aucun commentaire:

Enregistrer un commentaire