Get checkbox value in PHP
<form action="index.php" method="post">
<input type="checkbox" name="language[]" value="php" />PHP<br />
<input type="checkbox" name="language[]" value="html" />HTML<br />
<input type="checkbox" name="language[]" value="java" />Java<br />
<input type="checkbox" name="language[]" value="c++" />C++<br />
<input type="submit" value="send" />
</form>
foreach($_POST['language'] as $value)
{
echo 'Checked: '.$value.' ';
}
If you check all the checkboxes, this script will output:
Checked: php
Checked: html
Checked: java
Checked: c++
No comments:
Post a Comment