I have made a very simple form, just to see if I'm doing the right thing when submitting data in PHP. It just consists of three radio buttons and nothing else. Right not, I don't get the value in $_POST as i expect.
The form:
<form name='testform' action='test.php' method='post'>
<input type='radio' name='testbutton' value='larry' />
<input type='radio' name='testbutton' value='curly' />
<input type='radio' name='testbutton' value='moe' />
<input type='submit' value='Submit'>
</form>
The script, test.php:
if($_POST['testbutton'] == 'larry') {
echo "You picked Larry";
} elseif($_POST['testbutton'] == 'curly') {
echo "You picked Curly";
} else {
echo "You picked Moe";
}
The code returns no errors but whatever button I choose, I always get Moe, even when selecting no button at all. Using var_dump($_POST) gives nothing, an empty space. Using print_r($_POST) give 1, no matter what I pick. I can't find what I'm doing wrong here.
Btw, I know that this code is not optimal but I'm just testing things here.