PHP: Stocker les valeurs d’une case à cocher dans un tableau

Author:


Download

<html>
<head>
 
</head>
<body>
<?php
$fruits = $_GET["fruits"];
if (!empty($fruits)){
    echo "Les fruits séléctionnés sont: <strong>";
    foreach($fruits as $elem){
        echo ''.htmlentities($elem);
    }
    echo "</strong>.";
}
else {
    echo ('
<form action="'. htmlentities($_SERVER["PHP_SELF"]).'" method="GET">
<fieldset>
            <label>
                Orange
<input type="checkbox" name="fruits[]" value="Orange" />
            </label>
            <label>
                Banane
<input type="checkbox" name="fruits[]" value="Banane" />
            </label>
            <label>
                Pomme
<input type="checkbox" name="fruits[]" value="Pomm" checked="checked" />
            </label>
        </fieldset>
<input type="submit" value="Envoyer" />
    </form>
 
 ');
    }
?>
</body>
</html>

Leave a Reply

Your email address will not be published. Required fields are marked *


7 − = four