I've been working my way through the PHP Beginners Tutorial (http://www.phpcomplete.com/tutorials/?i ... adtutorial) - I'm following the logic and even able to do some problem solving when stuff isn't working but I've come up against one I have no idea how to clear up. I've got to "checkboxes" - I've set up an HTML form with two checkboxes and a submit and then set up a checkboxTest.php - code:
<?php
if($Checkbox1)
{
echo("The first checkbox was checked<br>\n");
}
if($Checkbox2)
{
echo("The second checkbox was checked<br>\n");
}
?>
With the code this way - nothing happens.
The obvious candidate to change is the "if"
if $_POST['Checkbox1']
However that returns an error message about expecting '(' in line 2 so I have no idea what else to try.
Please help.
thanks
Judith
There's also a second
using checkboxes
Moderator: General Moderators
This should work providing your using the POST method, otherwise replace _POST with _GET.
Code: Select all
if ($_POST['Checkbox1'])It might be worth noting that in recent releases of PHP, it has become default to NOT auto-populate variable with GET/POST/COOKIE infos. this is a 'good thing' in my book, as it makes thing that little bit more secure. (No cookie spoofing)
Try using the superglobals $_GET[], $_POST[] and $_COOKIE[] instead.
Try using the superglobals $_GET[], $_POST[] and $_COOKIE[] instead.