how can i put the value 1 or 0 into checkbox if we checked then 1 otherwise 0?
If you want to tick a box depending on the input to the form when re-echoing out that form, then you simply see whether it is set to 1 or 0 in your code.
You then echo the box to being checked when you write the code, depending on the value, e.g. like this:
<?php
$checked = $_POST[checked];
//this contains 1 if the box was checked and 0 otherwise
echo "<form action='blah.php' method='post'>
This checkbox will be ticked if you selected it on the previous page:";
echo "<input type='checkbox' name='checked'";
if($checked) { echo "CHECKED"; }
echo ">";
echo "<input type='submit' name='submit' value='send form'>";
echo "</form>";
?>
Comment on this Question and Answer >>>
ASK A QUESTION
More other PHP Questions
How do I add comments to my PHP script?How do I define a constant in PHP?
How do I find the timestamp for a particular date?
What is a constant in PHP?
How can I stop my PHP script timing out?
