Jump to content

'if'fing checkbox values.


Thauwa

Recommended Posts

Status - I have an HTML form, which has checkboxes named c1, c2, c3 & c4.

            When checked, the value (thing I want to insert to mysql) must be 'yes', and the remaining must be valued 'no'.  ???

 

Situation- I can't find how to do it.  :-\

 

Help! Does anyone know how to achieve this? Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/152186-iffing-checkbox-values/
Share on other sites

When a checkbox is unchecked, nothing is sent via POST. When a checkbox is checked, it's html value feild is sent. For setting a variable to yes or no if the checkbox is checked or unchecked, you can check it using the isset function.

 

$c1 = (isset($_POST['c1'] ? "yes" : "no");
$c2 = (isset($_POST['c2'] ? "yes" : "no");
$c3 = (isset($_POST['c3'] ? "yes" : "no");
$c4 = (isset($_POST['c4'] ? "yes" : "no");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.