Hi Sir,
I creating a form with checkbox
for example I checked the Add Employee and Upload Employee, after I click the Submit button
the output is 2 and 3 which is correct but only the Upload Employee was checked.
How can it be that the Add Employee and Upload Employee was checked.
Also how can save checkbox check in the database.
[CODE]
if(isset($_POST[‘submit’]))
{
if(!empty($_POST[‘access’])) {
$access = $_POST[‘access’];
echo “You chose the following color(s): <br>”;
foreach ($access as $access_id){
echo $access_id.”<br />”;
}} // end brace for if(isset
else {
echo “You did not choose a color.”;
}
}
<input type=”checkbox” name=”access[]” id=”access” value=”1″ <?php if($access_id==1) echo ‘checked=”checked”‘; ?>>Search/View Employee Information<br>
<input type=”checkbox” name=”access[]” id=”access” value=”2″ <?php if($access_id==2) echo ‘checked=”checked”‘; ?>>Add Employee<br>
<input type=”checkbox” name=”access[]” id=”access” value=”3″ <?php if($access_id==3) echo ‘checked=”checked”‘; ?>>Upload Employee<br>
<input type=”checkbox” name=”access[]” id=”access” value=”4″ <?php if($access_id==4) echo ‘checked=”checked”‘; ?>>Permission<br>
<input type=”checkbox” name=”access[]” id=”access” value=”5″ <?php if($access_id==5) echo ‘checked=”checked”‘; ?>>Vacation<br>
<input type=”checkbox” name=”access[]” id=”access” value=”6″ <?php if($access_id==6) echo ‘checked=”checked”‘; ?>>Calendar Event<br>
<input type=”submit” name=”submit” id=”submit” value=”Submit”>
Thank you