Wednesday, April 16, 2008

Getting Checkbox Values in PHP

<?php
if(isset($_REQUEST['lang']))
{
$lang=$_REQUEST['lang'];
foreach ($lang as $language)
{
echo "$language is checked <br />";
}
echo "Selected Array: ";
print_r($lang);
}
?>
<html>
<head>
<title>TEST</title>
</head>
<body>
<form method="post" action="#">
Please choose language:<br />
<input type="checkbox" name="lang[]" value="JAVA">JAVA<br />
<input type="checkbox" name="lang[]" value="VB">VB<br />
<input type="checkbox" name="lang[]" value="PHP">PHP<br />
<input type="submit" value="submit" name="submit">
</form>
</body>
</html>

No comments: