Passing the value using checkbox with html and php

a) post.phpb) edit.phpi am using the checkbox in both the form to set the binary value (0 and 1) to set the status for approve.to process the value from the checkbox in the post.php i am using the code which checks and assume that if the checkbox is checked then the value will be 1 other wise it is 0 by default\[code\]if (isset($_POST['ad_approve'])) $ad_approve = htmlspecialchars(strip_tags(mysql_real_escape_string($_POST['ad_approve']))); else { $ad_approve = 0; }\[/code\]Now in the edit.php form i retrieve the data from the database and set the checkbox accordingly . if the approve has the value 1 then it is checked by default . look onto the following code\[code\]<input name="ad_approve" type="checkbox" value="http://stackoverflow.com/questions/3596198/1" <?php if($approve==1) echo 'checked="checked"';?> />\[/code\]in the above code i cannot apply the same logic to catch the value from ad_approve i.e(by checking isset()) because if the value is 1 by default and if i try unchecking the checkbox then automatically the program assume that the value is set because it has been changed from checked to unchecked. now in the edit.php how do i again process the value from it such that if the checkbox is checked hold the value as 1 otherwise 0, ??
 
Back
Top