Forum Moderators: coopster
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("test", $db);
$sql = "INSERT INTO form_checker VALUES(NULL, '$name', '$des_field')";
mysql_query($sql);
?>
<form action="example.php" method="Post">
Name: <input type="text" size="30" name="name"><br>
Age: <input type="checkbox" name="des_field" value="age"><br>
Sex: <input type="checkbox" name="des_field" value="sex"><br>
Location: <input type="checkbox" name="des_field" value="location"><br>
<input type="Submit" value="Submit">
</form>
Any help would be appreciated.
Thanks in advance
Age: <input type="checkbox" name="des_field[age]" value="age"><br>
Sex: <input type="checkbox" name="des_field[sex]" value="sex"><br>
Location: <input type="checkbox" name="des_field[location]" value="location"><br>
into your HTML. When you fill in a form where three fields have the same name then only the last value in the form will get sent if all of them are checked. What exactly are you try to achieve on the form?
In the PHP, given the HTML above, you can extract the information by using $des_field['age'], $des_field['sex'], etc.
I tried the way you offered but it won't work. In my web site there will be a list of choices (offers). And the users will have to choose at least three items from the list. I am trying to put these data, chosen from list in one field of the table using checkboxes.
I want to offer users multiple choice, and the data to be stored in one field.
Thanks again, I really appriciate your help
David
$string=implode(',',$des_field);
and then insert $string in the appropriate column. implode [php.net] will take an array and join the parts together with the specified delimiter, in this case a comma.
I hope that helps.