A
Anonymous
Guest
Guys, i always get my error message, i cant insert the values from the checkbox. what isw wrong with my code?
thank you
[/code]
thank you
Code:
<?php
require_once('dbconnect.php');
if (isset($_POST['submit'])) {
$chk = join (',' , $_POST['check']);
$query = "INSERT INTO test (check) VALUES ('$chk')";
if ($result = @mysql_query ($query))
{
echo 'OK';
}
else
{
echo 'ERROR';
}
}
else
{
?>
<form enctype="multipart/form-data" action="test_add.php" method="post">
<p>Sample Checkbox Form</p>
<p>
<input type="checkbox" name="check[]" value="Coke">
Coke </p>
<p>
<input type="checkbox" name="check[]" value="Sprite">
Sprite</p>
<p>
<input type="checkbox" name="check[]" value="Pepsi">
Pepsi</p>
<p>
<input type="submit" name="submit" value=" submit" />
</p>
</form>
<?
}
?>