{easy} Help with form and switch's

Discussion in 'PHP' started by Dirty-Rockstar, Apr 7, 2007.

  1. #1
    Im lost. oober new to php and i cannot seem to get this to work. Trying to get a user to choose between 3 players. and then for the page to print out who the user picked. It only seems to pick player 1 no matter what radio button i choose. I think i has something to do with the action in the form. help is appriciated

    <?
    $chooseaplayer=$_POST[chooseaplayer];
    
    
    
    if(isset($_POST[chooseaplayer])) {
    
    
    switch ($playerchosen)
    {
    case $player1:
    
    print "you have chosen player 1";
    break;
    
    case $player2:
    
    print "you have chosen player 2";
    break;
    
    case $player3:
    print "you have chosen player 3";
    break;
    
    default:
    print "Some error";
    break;
    
           }
    
    }
    
    
    print "
    
    
    <form method='POST' action='$playerchosen'>
    <input type='radio' name='player1' value='$player1'> player 1
    <br>
    <input type='radio' name='player2' value='$player'2> player 2
    <br>
    <input type='radio' name='player3' value='$player3'> player 3
    <br>
    <input type=submit name=chooseaplayer value=Choose>
    </form> "
    
    
    ?>
    PHP:
     
    Dirty-Rockstar, Apr 7, 2007 IP
  2. Dirty-Rockstar

    Dirty-Rockstar Guest

    Messages:
    252
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    after reading my book i bought i realized there was an easier way. thanks. fixed it myself
     
    Dirty-Rockstar, Apr 7, 2007 IP