+ 3
HTML5 and PHP problems?
I have a script <input type="checkbox" name="test"></input> <?php if(isset($_POST['test'])) { echo "eh"; } ?> It prints out a checkbox and this: if(isset($_POST['test'])) { echo "eh"; } ?> Whats wrong?
6 Answers
+ 3
Try this:
<form action="" method="post">
<label><input type="checkbox" name="test" value="eh"></input>eh</label>
<br />
<input type="submit" value="Send" />
</form>
<?php
if(isset($_POST['test'])) {
echo $_POST['test']; // "eh" output if checked
}
?>
+ 4
Save the code in php file.
Code is not really complete, add form and submit input tags and appropriate attributes are needed.
+ 4
Action and method attributes are both needed.
If for submission to own page use this form tag:
<form action="" method="post">
+ 3
Nice, Is it good if I add a action attribute without method attribute?
+ 3
Awesome, thanks :)
+ 3
Alright I thought it was gonna be separate files, cool