I am having trouble using $_GET
with radio buttons.
4th<input type="checkbox" name="date" value="4th">
5th<input type="checkbox" name="date" value="5th">
6th<input type="checkbox" name="date" value="6th">
The user chooses what days they are available. Then I want to echo out what days the user selected:
<?php echo "You are available " . $_GET["date"] . "!"; ?>
The above code only echos out one. Not all three. Is there a way to do this?
checkbox
values are returned in an array as they share the same index, so you need to usename="date[]"
in your HTML.If you want to know more, just try to
print_r($_GET['date']);
and see what you get.And you've tagged your question as
radio
so would like to inform you thatradio
andcheckbox
are 2 different things,radio
returns single value, wherecheckbox
can return multiple.Name will be an array
Then get value like this
You can use in php
Please use array to get multiple value -
Code:
I am not checking above code. I guess it will work.
You could give each input an id:
Then echo it like this: