dimanche 3 janvier 2016

checkbox group in php

I picked up a checkbox group for my members to fill in during registration and I want the results from what they have chosen to show on there profile page heres the code in full for checkbox Select Your Technical Exposure: C/C++ Java PHP HTML/CSS UNIX/LINUX `

and here is the code from the checkbox value file

    <?php
    if(isset($_POST['submit'])){
    if(!empty($_POST['check_list'])) {
    // Counting number of checked checkboxes.
    $checked_count = count($_POST['check_list']);
    echo "You have selected following ".$checked_count." option(s): <br/>";
        // Loop to store and display values of individual checked checkbox.
    foreach($_POST['check_list'] as $selected) {
    echo "<p>".$selected ."</p>";
    }

    }
    else{
    echo "<b>Please Select Atleast One Option.</b>";
    }
    }
    ?>`

so far i have put the under the options i have in my site

then i put the following on profile.php

    <?php
    if(!empty($_POST['check_list'])) {
    // Counting number of checked checkboxes.
    $checked_count = count($_POST['check_list']);
    echo "You have selected following ".$checked_count." option(s): <br/>";
    // Loop to store and display values of individual checked checkbox.
    foreach($_POST['check_list'] as $selected) {
    echo "<p>".$selected ."</p>";
    }

    }
    else{
    echo "<b>Please Select Atleast One Option.</b>";
    }

    ?>`

and when I attempt to choose a selection I get the following returned to my

    profile.php

Please Select At least One Option.

What should I be doing with this to get it working and help would be much appreciated.




Aucun commentaire:

Enregistrer un commentaire