View Single Post
  #3 (permalink)  
Old 06-17-09, 01:10 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
You weren't being very specific, so I can think of at least a couple different possibilities.

Say if you wanted to concatenate id1 and id2 and send the value to another page,
then you may do it like this:
PHP Code:

<?php
if(!empty($_POST["id1"]) && !empty($_POST["id2"]))
{
 
$id $_POST["id1"].$_POST["id2"];
 
header("location: mypage.php?id=$id");
 }
?>
<html>
<head>
<title></title>
</head>
<body>
<form action="#" method="POST">
First Id: <select name="id1">
<option value="">Select first id ...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<br />
Second Id: <select name="id2">
<option value="">Select second id ...</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
</select>
<p>
<input type="submit" value="Submit">
</p>
</form>
</body>
</html>
But if you wanted to concatenate id1 and id2 and send the user to a different page depending on the resultant value,
then you could do it like this:
PHP Code:

<?php
if(!empty($_POST["id1"]) && !empty($_POST["id2"]))
{
 switch (
$_POST["id1"].$_POST["id2"])
 {
  case 
"101":
   
header("location: page1.php");
   break;
  case 
"102":
   
header("location: page2.php");
   break;
  case 
"103":
   
header("location: page3.php");
   break;
  case 
"201":
   
header("location: page4.php");
   break;
  case 
"202":
   
header("location: page5.php");
   break;
  case 
"203":
   
header("location: page6.php");
   break;
  case 
"301":
   
header("location: page7.php");
   break;
  case 
"302":
   
header("location: page8.php");
   break;
  case 
"303":
   
header("location: page9.php");
   break;
  }
 }
?>
<html>
<head>
<title></title>
</head>
<body>
<form action="#" method="POST">
First Id: <select name="id1">
<option value="">Select first id ...</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<br />
Second Id: <select name="id2">
<option value="">Select second id ...</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
</select>
<p>
<input type="submit" value="Submit">
</p>
</form>
</body>
</html>
__________________
Jerry Broughton

Last edited by job0107; 06-17-09 at 01:25 AM.
Reply With Quote