mardi 23 août 2016

PHP Checkbox is not giving Any value after checked in

Assalam o Alaikum. I'm trying to edit my selections using checkbox method, the values which are previously in database are checked while the other's are not. what I'm trying to do is check other checkbox or uncheck the previous selected check box but when i submit my edition nothing got happen because It is not getting values from the checkboxes I don't know why. Here is my Code. Thankyou

       <form  class="form-horizontal" role="form" action="#" method="post" name="add_Institute">
<?php  
for($i=0;$i<count($name)-1;$i++)//here name is array which gets data from db
                {   if($name[$i]=='Matric Arts')
                    $dbvalue=$name[$i];
                } ?>
                <label for="tag_1">Matric Arts</label>
                <input type="checkbox" name="check_DegreePrograms[]" id="tag_1" value="Matric Arts" <?php
                $value="Matric Arts";
                echo ( $dbvalue==$value ? 'checked' : '');?>>
                <?php  for($i=0;$i<count($name)-1;$i++) 
                {   if($name[$i]=='Matric Science')
                    $dbvalue=$name[$i];
                } ?>
                <label for="tag_2">Matric Science</label>
                <input type="checkbox" name="check_DegreePrograms[]" id="tag_2" value="Matric Science" <?php
                $value="Matric Science";
                echo ( $dbvalue==$value ? 'checked' : '');?>>
<input type="Submit" name="Submit" value="Submit" class="btn btn-success pull-right"/>
    </form>
 $pets="";
            if(isset($_POST['submit'])){//to run PHP script on submit
if(!empty($_POST['check_DegreePrograms'])){
 foreach($_POST['check_DegreePrograms'] as $selected){
     $pets .= $selected . ",";
     $flag = } 
}
}   




Aucun commentaire:

Enregistrer un commentaire