I have checkboxes with name statuses. This is how i am doing it:
$_SESSION['statuses'] = mysql_real_escape_string($_POST['statuses']);
When i insert it that is how i am doing it:
$insert = "INSERT INTO submitted (statuses)
VALUES ('".$_SESSION['statuses']."')";
$query = mysql_query($insert) or die ("Error: ".mysql_error());
Problem is nothing that is checked gets inserted into the database, so how do i insert checked entries?
NEW/UPDATE:
This is how the checkbox form looks like:
<input type="checkbox" name="statuses" value="something">
<input type="checkbox" name="statuses" value="something">
<input type="checkbox" name="statuses" value="something">
<input type="checkbox" name="statuses" value="something">
<input type="checkbox" name="statuses" value="something">
<input type="checkbox" name="statuses" value="something">
Perhaps the issue might lie in the mark up you have written for the form. Here’s and example:
Notice that
optionsis set asoptions[]. This allows an array of all checked options to appear in your POST super variable.If you do:
You should then get an array containing all the checked values.
Then you can do something like:
Then insert into the database:
Update:
On each page of the form you should have something like escape the values and save it to the session. This then saves the values from each page to the user’s session: