Mysqli Php - User Input Multiple Choice Checkboxes Into 1 Record
beginner here. i have a nice mysqli user input going to where people fill out a form and it gets entered into my database. For example im using $category = $_POST['category'];
Solution 1:
The attribute "id" is only used by CSS and javascript to refer to the specific element. What you want here, is give the elements a name. like so:
<div id="checkboxes">
<label for="one"><input type="checkbox" name="one"id="one" />First checkbox</label>
<label for="two"><input type="checkbox" name="two"id="two" />Second checkbox</label>
<label for="three"><input type="checkbox" name="three"id="three" />Third checkbox</label>
</div>
You can then check in your $_POST for $_POST['one'] or $_POST['two'] or $_POST['three']. They should be either missing entirely (use isset()) or should be posted as the value "on"
if (isset($_POST['one']) && $POST['one'] === "on"){
// do stuff for checkbox one
}
Post a Comment for "Mysqli Php - User Input Multiple Choice Checkboxes Into 1 Record"