I am trying to use an HTML form with radio buttons to choose a file to use as an include. It fails and I would like to know why ... Can anyone please identify my misteak?

Here is my HTML

<form name="form1" action="pdfmaker.php" method="post">
      <p><input type="radio" name="formradio1" value="1">Choice 1<br>
       <input type="radio" name="formradio1" value="2">Choice 2<br>
       <input type="radio" name="formradio1" value="3">Choice 3<br>
       <input type="radio" name="formradio1" value="4">Choice 4<br>
       <input type="radio" name="formradio1" value="5">Choice 5<br>
       <input type="radio" name="formradio1" value="6">Choice 6</p>
       <p><input type="submit" name="Submit" value="Submit"></p>
       </form>

and here is my PHP ...

switch ($formradio1) {
case 1:
    include("Choice_1.php");
    break;
case 2:
    include("Choice_2.php");
    break;
case 3:
    include("Choice_3.php");
    break;
case 4:
    include("Choice_4.php");
    break;
case 5:
    include("Choice_5.php");
    break;
case 6:
    include("Choice_6.php");
    break;
}

My problem is that no matter which radio button I select, they all seem to use Choice_1.php as the include.

Any assistance will be appreciated.

Kirk

I think I found the answer ... I changed my PHP code to

$selected_radio = $_POST['formradio1'] ;
switch ($selected_radio) {
case 1:
    include("Choice_1.php");
    break;
case 2:
    include("Choice_2.php");
    break;
case 3:
    include("Choice_3.php");
    break;
case 4:
    include("Choice_4.php");
    break;
case 5:
    include("Choice_5.php");
    break;
case 6:
    include("Choice_6.php");
    break;
}

Seems to be working. Sorry to have been a bother.

Kirk

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.