What are the key words/variables for radio and check boxes?
if checkbox== checked?
Thats for anyhelp
forms
Moderator: General Moderators
it depends 
try this one
<input type="checkbox" name="single" /> -> $_POST['single'] == 'on' or not set
<input type="checkbox" name="cbwithvalue" value="myValue"/> -> $_POST['cbwithvalue'] == 'myValue' or not set
<input type="checkbox" name="cbarray[]"/> -> $_POST['cbarray'] is an array with numerical indicies for all checked checkboxes -> 'on' (no position information is stored; always beginning at 0)
<input type="checkbox" name="cbarrayV[]" value="A"/> -> $_POST['cbarrayV'] is an array with numerical indicies for all checked checkboxes holding each value of the corresponding input-element
just remeber that if your're using name="cbarray[]" without value property you will loose the information which checkboxes have been checked
try this one
Code: Select all
<html><body>
<form method="POST">
<fieldset><legend>single checkboxes</legend>
<input type="checkbox" name="single" />a single checkbox<br/>
<input type="checkbox" name="cbwithvalue" value="myValue"/>a single checkbox with value<br/>
</fieldset>
<fieldset><legend>checkboxe-array without value</legend>
<input type="checkbox" name="cbarrayї]"/>checkbox 'array' #1<br/>
<input type="checkbox" name="cbarrayї]"/>checkbox 'array' #2<br/>
<input type="checkbox" name="cbarrayї]"/>checkbox 'array' #3<br/>
</fieldset>
<fieldset><legend>checkboxe-array with value-properties</legend>
<input type="checkbox" name="cbarrayVї]" value="A"/>checkbox 'array' with value #1<br/>
<input type="checkbox" name="cbarrayVї]" value="B"/>checkbox 'array' with value #2<br/>
<input type="checkbox" name="cbarrayVї]" value="C"/>checkbox 'array' with value #3<br/>
</fieldset>
<input type="submit"/>
</form>
<pre>
<?php
print_r($_POST);
?>
</pre>
</body>
</html><input type="checkbox" name="cbwithvalue" value="myValue"/> -> $_POST['cbwithvalue'] == 'myValue' or not set
<input type="checkbox" name="cbarray[]"/> -> $_POST['cbarray'] is an array with numerical indicies for all checked checkboxes -> 'on' (no position information is stored; always beginning at 0)
<input type="checkbox" name="cbarrayV[]" value="A"/> -> $_POST['cbarrayV'] is an array with numerical indicies for all checked checkboxes holding each value of the corresponding input-element
just remeber that if your're using name="cbarray[]" without value property you will loose the information which checkboxes have been checked
Volka answered you!!
Or if you are using GET method then use the $_GET array instead.
Code: Select all
if ($_POSTї'siteOFF'])
{
// your checkbox is set!
}