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
Can I include Javascript in my PHP code?What does the @ character do in PHP?
Can PHP create PDF files for me?
What are autoglobals?
Can I spellcheck my text using PHP?
