I am trying to post the value post the value of the checkboxes to my database. If all the checkboxes are selected the checkboxes are sending the value 1
to the database. But when a checkbox is not selected the post dont works.
On the PHP page that post the data to the database I get Notice: Undefined index
for the checkboxes that are not selected. Witch means that the not selected textboxes are sending an empty post.
Is there a way to fix this? Can I define a value for the not selected textboxes?
Here are my textboxes:
<input type="checkbox" name="psv1" id="psv1" value="1" class="flat" />
<input type="checkbox" name="psv2" id="psv2" value="1" class="flat" />
<input type="checkbox" name="psv3" id="psv3" value="1" class="flat" />
<input type="checkbox" name="psv4" id="psv4" value="1" class="flat" />
<input type="checkbox" name="psv5" id="psv5" value="1" class="flat" />
As you see, the textboxes are posting the value 1
when they are selected.
I am trying to get the value of the textboxes with the following in the PHP script:
$psv1 = $_POST['psv1'] ;
$psv2 = $_POST['psv2'] ;
$psv3 = $_POST['psv3'] ;
$psv4 = $_POST['psv4'] ;
$psv5 = $_POST['psv5'] ;
I get the Notice: Undefined index
for variables that are not selected.