1 page that can post to multiple pages

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
mistux
Forum Newbie
Posts: 5
Joined: Wed Oct 22, 2003 6:54 pm
Location: Indiana, USA

1 page that can post to multiple pages

Post 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?
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post 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.
Post Reply