vendredi 31 juillet 2020

Update database with html Switch Checkbox php if statement

Hope someone help sort this for me, even if its another solution, as I have hit the php brick wall

I have a form with a checkbox switch in it

                       <div class="col-md-3">
                        <input type="hidden" name="needclean" value="No" checked />
                        <div class="switch">
                        <label>NO<input type="checkbox" name="needclean" value="Yes"><span class="lever switch-col-green"></span>YES</label>
                        </div>
                        </div>

What I want to happen is when the user clicks "Yes" it populates the cell in the DB called "Status" to "Needs Cleaning" and if the user Clicks "No" it populates the "Status" cell in the DB to "Good to Go"

I have tried this

<?php
                    if(isset($_POST['needclean'])){
                    $clean = $_POST['needclean'];
                }
                if(isset($needclean) == "Yes"){ 
                    echo '<input type="hidden" name="status" value="Needs Cleaning" />';
                } else {
                     echo '<input type="hidden" name="status" value="Good to Go" />';
                }

                    ?>

But all it does is populate the "Status" cell with "Good to go" no matter if I select Yes or No

I hope I have explained this and if you need any more info please let me know

Thanks in advance for any help




Aucun commentaire:

Enregistrer un commentaire