My question is that first i need to create the 10 checkboxes which i have already done and then when i set the value of any of the checkboxes as checked, it should be saved in a session after clicking on the submit button.After clicking on the submit button the values of the checkboxes that were checked should remain checked and should not be reset.And then after checking the values of checkboxes time and again on clicking on submit button, the checked values should be saved in session again such that the duplicate values are not allowed in the session. Since i am novice in php i have tried a lot but without success,

Member Avatar for diafol
<?php
$total = (isset($_POST['mycheck'])) ? array_sum($_POST['check10']) : 0;
$output = "";
$label = array("item 1","prize 2"," fallow 3"," round 4","prism 5","echo 6"," tango 7","ent 8","thorn 9"," elbow 10");
for($x=0;$x<count($label);$x++){
	$bt = pow(2,$x);
	$chk = ($total & $bt) ? ' checked="checked"' : '';
	$output .= "<input id=\"item_$x\" type=\"checkbox\" name=\"mycheck[]\" value=\"$bt\"$chk /> <label for=\"item_$x\">{$label[$x]}</label>\n";
}
?>

and

<form method="post">
<?php echo $output;?>
<input type="submit" value="sub" />
</form>

You could save to session too:

if($total)$_SESSION['form_total'] = $total;

remember the

session_start()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.