Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h1>come usare php e i check box</h1>
- <form name='tag' method='post' action='php_e_checkbox.php'>
- <b>che frutta ti piace?</b><br>
- <input type='checkbox' name='frutta[]' value='mela' />mela<br>
- <input type='checkbox' name='frutta[]' value='pera' />pera<br>
- <input type='checkbox' name='frutta[]' value='fragola' />fragola<br>
- <input type='checkbox' name='frutta[]' value='banana' />banana<br>
- <input type='submit' value='invia'>
- </form>
- <br>
- <a href='php_e_checkbox.php'>back</a><br>
- <?php
- $out ="";
- if( isset($_POST['frutta']) )
- {
- $tags = $_POST['frutta'];
- foreach( $tags as $v)
- {
- $out .= "$v, ";
- }
- echo "hai selezionato: <b>$out</b>";
- }
- $info = "<code>".htmlentities("<input type='checkbox' name='frutta[]' value='banana' />banana<br>")."</code>";
- echo "
- <h2>importante</h2>
- $info<br>
- <br>la proprieta' <code>name='tag[]'</code> senza le parentesi quadre non permetterebbe il passaggio di dati multipli, quindi restituisce un Array.
- ";
- ?>
- <br><br><img src='img/cupeicbm.png' title='come usare php e i check box' width='800'/>
Advertisement
Add Comment
Please, Sign In to add comment