Do you mean which attribute do you set so that the checkbox is checked?
<input type="checkbox" name="privacy_policy" id="privacy_policy" value="yes" checked="checked" />
EDIT: What I would do, is bind some code to the checkbox's click event (using a library like jQuery), like the following:
$(document).ready(function() {
$("#privacy_policy").click(function() {
// block the checkbox
$(this).attr("disabled", "disabled");
var checked = 0;
if($(this).is(":checked")) {
checked = 1;
}
// send the checked state to PHP script
// if the update has been successful, the script echos a '1'
$.post('account.php', { checked: checked, function(resp) {
// update has been successful
if(resp == 1) {
// unblock the checkbox, the current
// checked state reflects the stored value
$(this).removeAttr("disabled");
} else {
alert("settings could not be updated");
}
});
});
});
That will handle the real-time manipulating of that particular option's setting every time the checkbox is clicked. (I think that's what you meant, anyway). You just need to act on the $_POST['checked']
variable internally.
To set up the initial state of the checkbox based on a stored value (the first time the page loads), just use short tags, e.g.:
<?php
$isChecked = $_SESSION['someSetting']; // 1 or 0, for example
?>
<input type="checkbox" name="privacy_policy" id="privacy_policy" value="yes" <?php if($isChecked) echo 'checked="checked"'; ?>/>