Jump to content

User selects two options, posted variables complete redirect link


msaz87

Recommended Posts

Hi all,

 

I'm trying to set up a very short form that posts two variables and upon submission, redirects the user to a page -- and the two variables are part of the URL, but I can't seem to get it right.

 

Here's my code:

<?

$location_ID = "5";
$league_ID = "8";

$week_results = $_POST['week_results'];
$division_results = $_POST['division_results'];

$results_link = "http://www.fasports.com/manager/view_standings.php?location_id=$location_ID&league_id=$league_ID&division_id=$division_results&week=$week_results";

$divisions = "
<option value=\"25\">A/B</option>
<option value=\"26\">C</option>
<option value=\"27\">D</option>
<option value=\"28\">E1</option>
<option value=\"29\">E2</option>
";

$weeks = "
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
";

?>

 

and the portion involving the user:

					<b>Results</b><br/><form action="process.php" method="post">
				Division: <select name="division_results"><? echo($divisions); ?></select><br/>Week: <select name="week_results"><? echo($weeks); ?></select><input type="Submit" value="View"></form><br/>

 

and finally, process.php...

<?php
header( 'Location: '.$results_link.'');
?>

 

I'm very new to php... so I apologize in advance for any novice errors...

 

Thanks so much for your help!

The redirect below will work if you don't put the http:// in your link:

 

$results_link = "http://www.fasports.com/manager/view_standings.php?location_id=$location_ID&league_id=$league_ID&division_id=$division_results&week=$week_results";

 

Remove the http:// from the previous code, and then add the following code to your process.php.

 

<?php header( "Location: http://$results_link "); ?>

 

That's just the redirect part, who knows if the previous bit of code (your form) works. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.