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?
1 page that can post to multiple pages
Moderator: General Moderators
You could use include() to choose which PHP page to include based on the form.
Heres an example:
form.php
selection.php
This code is untested, don't know if it will work.
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>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;
}
?>