php method to get the value of the check box:
HTML code:
<form id="form1" name="form1" method="post" action="checkbox.php"> <input type=checkbox name=checkbox[] value="1"> <input type=checkbox name=checkbox[] value="2"> <input type=checkbox name=checkbox[] value="3"> <input type=checkbox name=checkbox[] value="4"> <input type=checkbox name=checkbox[] value="5"> <input type="submit" name="button" id="checkbox" value="提交" /> </form>
PHP code:
<?php $text1=$_POST['checkbox']; for($i=0;$i<count($text1);$i++) { $yourwant = $text1[$i]; echo $yourwant."<br/>"; } ?>
The predefined $_POST variable is used to collect values from the form with method="post".
Information sent from a form with the POST method is invisible to anyone (will not be displayed in the browser's address bar), and there is no limit on the amount of information sent.
Recommended: php server
The above is the detailed content of How to get the value of checkbox in PHP. For more information, please follow other related articles on the PHP Chinese website!