Page 1 of 1

1 page that can post to multiple pages

Posted: Wed Oct 22, 2003 6:54 pm
by mistux
I have a PHP page that lets the user select a team and then a season and I want the user to be able to click on one of several buttons that then sends those selections to the PHP page associated with the button. I have a seperate selection page for Goals, Penalties, and Assists.

I am not sure if this is is a PHP issure or just an HTML issue. Right now I have on the Goal selection page:

<form method="post" action="goal_rankings.php">

I'd like to have just one selection form that will then post to whatever specific PHP pages that the user clicks on.

How do I do this?

Posted: Wed Oct 22, 2003 8:09 pm
by DuFF
You could use include() to choose which PHP page to include based on the form.

Heres an example:

form.php

Code: Select all

<form method="post" action="selection.php">
<select name="selection">
<option value="goals">Goals</option>
<option value="penalties">Penalties</option>
<option value="assists">Assists</option>
</select>
</form>
selection.php

Code: Select all

<?php
switch ($selection)
{
    case 'goals':
       include("goal_rankings.php");
        break;
    case 'penalties':
       include("penalties.php");
        break;
    case 'assists':
       include("assists.php");
        break;
    default:
       echo "<b>Error:</b> Selection undefined";
        break;
}
?>
This code is untested, don't know if it will work.