Radio buttons & $_POST

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
xNuManx
Forum Newbie
Posts: 13
Joined: Wed Aug 27, 2008 9:17 am

Radio buttons & $_POST

Post by xNuManx »

Hello, I am trying to get this code to work, but its not. here's what i have:

Code: Select all

        <input type="radio" name="genre" value="Reggaeton">Reggaeton<br>
        <input type="radio" name="genre" value="Merengue">Merengue<br>
        <input type="radio" name="genre" value="DominicanHipHop">Dominican Hip-Hop<br>
        <input type="radio" name="genre" value="Rap">Rap<br>
        <input type="radio" name="genre" value="Rock">Rock<br>
 
And my $_POST:

Code: Select all

if($_POST['genre'] == "Reggaeton") {
$chlist = 1;
 } elseif($_POST['genre'] == "Merengue") {
$chlist = 2; 
} elseif($_POST['genre'] == "DominicanHipHop") {
$chlist = 3; 
} elseif($_POST['genre'] == "Rap") {
$chlist = 4; 
} elseif($_POST['genre'] == "Rock") {
$chlist = 5; 
}
But my $_POST is not working, Any help please!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Radio buttons & $_POST

Post by requinix »

Code: Select all

print_r($_POST);
Make sure the genre shows up in there. Sure you're using POST and not GET?
xNuManx
Forum Newbie
Posts: 13
Joined: Wed Aug 27, 2008 9:17 am

Re: Radio buttons & $_POST

Post by xNuManx »

tasairis wrote:

Code: Select all

print_r($_POST);
Make sure the genre shows up in there. Sure you're using POST and not GET?
Yeah i am using post, and genre does comes out there:
[genre] => Reggaeton
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Radio buttons & $_POST

Post by requinix »

So how do you know it's not working? Have you checked $chlist to see if that's right?
Post Reply