Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

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


{filelink=12459}

<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>

No comments yet.

Leave a Comment