I'm still studying php html, any help is appreciated.
I have code like this:
<form method="post">
<input type="checkbox" id="option1" name="option" value="<?php echo "Hello World!"; ?>" />
<label for="option1"> Do you want to print Hello World? </label> <br />
<input type="checkbox" id="option2" name="option" value="<?php echo "Hello Brother" ?>" />
<label for="option2"> Do you want to print Hello Brother?</label> <br />
<input type="checkbox" id="option3" name="option" value="<?php echo "Hello Human" ?>" />
<label for="option3"> Do you want to print Hello Human?</label> <br />
<br />
<br />
<input type="submit" id="Submit" name="Submit" value="Submit"/>
</form>
<?php
if(empty($_POST["option"])){
echo "You need to choose at least one!";
}
else {
echo "Print successful!";
}
?>
I want to have function that if checked, then print the value in different php file. I also have problem that when I checked and submit, the check mark disappeared.
I want it to be like, if checked then true, print the value. if not checked then false, do not print the value. Any idea? Thank you very much!
You have to use
action="#"
in form tag and mentioned the page name.Working Demo: http://phpfiddle.org/main/code/brkr-u9st