I’m new to html so i’m unsure where im going wrong but i have the following code (i’m creating a form and adding values to the database when the user presses submit).
a checkbox nested in a form –
<label for="choice1">Windows 7</label>
<input type="checkbox" name="choice1"/>
and when the user presses ‘add button’ i’m trying to get the value and store it in a variable but it cannot find ‘choice1’.
$choice1=$_POST[‘choice1’];
but i get “Undefined index: choice1“. Why is this?
If the checkbox is checked, the browser sends its value with other variables.
If it’s not checked, it’s not sent.
Do this: