I have three pages I am trying to pass a variable from/ to.
My first page is a list of all teams. I click on the name of a team and capture it's team_id and I then get directed to the Movement page with the team name displayed above the form I am using. Passing between these two pages works.
On the Movement page I have a "Commanders Menu" dropdown box with options such as "Move", "Attack", and "Move and Attack". These three options send me to these other pages.
Here is my Movement page.
$id = intval($_GET['team_id']);
$sql = "SELECT * FROM " . $prefix . "_tc_ladderteams tclt WHERE team_id ='$id'";
$result = $db->sql_query($sql);
$info = $db->sql_fetchrow($result);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
} else {
$unitname = $info['name'];
}
Opentable()
?>
<center><H2><strong>Campaign Movement Orders for </strong></H2></center><br>
<center><H2><strong><?php echo $unitname ?></strong></H2></center><br>
<br>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
<center><b>Commanders Menu<br>
<select name="move" onchange="if(this.options[this.selectedIndex].value != 0){ document.location=this.options[this.selectedIndex].value; }">
<option value="0">--Choose option--</option>
<option value="modules.php?name=Campaign&file=Move&team_id=$id">Move</option>
<option value="modules.php?name=Campaign&file=Attack&team_id=$id">Attack</option>
<option value="modules.php?name=Campaign&file=MoveAttack&team_id=$id">Move and Attack</option>
</select>
</form>
<?php
echo"<table width=\"100%\" border=\"1\" cellspacing=\"1\" cellpadding=\"1\">"
."<tr><td>"
."<center><b><h2>Unit Movement Form</h2></center>"
."<br>"
."<br><center><p><b>Division Commanders must post the movement orders NLT Wednesday each week.</p>"
."<p>Units can only attack the enemy when the enemy is in the same territory. </p>"
."<p>Monday the strategic map is updated after matches are played over the weekend. Monday and Tuesday are for offensive/defensive planning. All match results should be reported in TitanCore no later than midnight Sunday or they may not be recognized.</p>"
."<br>"
."</table>";
CloseTable();
echo"<input type=\"hidden\" name=\"id\" value=\"$id\">";
echo"<input type=\"hidden\" name=\"team_id\" value=\"$team_id\">";
@include_once("footer.php");
?>
And here is my Move page:
$id = $_GET['team_id'];
$sql = "SELECT * FROM " . $prefix . "_tc_ladderteams tclt WHERE team_id ='$id'";
$result = $db->sql_query($sql);
$info = $db->sql_fetchrow($result);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
} else {
$unitname = $info['name'];
}
Opentable()
?>
<center><H2><strong>Campaign Movement Orders for </strong></H2></center><br>
<center><H2><strong><?php echo $unitname ?></strong></H2></center><br>
<br>
<!-- Move -->
<br>
<!--<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST"> -->
<form name="Move" action="modules.php?name=Campaign" method="post">
<H3><center>Move</center></H3>
<HR>
<?php
if ($op == "Move") {
//convert all the posts to variables:
$ateam_id = intval($_POST['team_id']);
$tid = intval($_POST['tid']);
$action = 'move';
//Insert the values into the correct database with the right fields
$result = $db->sql_query ("INSERT INTO " . $prefix . "_eto_movelog (log_id, ateam_id, tid, move_dt, action)".
"VALUES ('NULL','$ateam_id','$tid',CURRENT_TIMESTAMP(),'$action')");
$update = $db->sql_query("UPDATE " . $prefix . "_tc_teams SET tid = '$tid' WHERE team_id = $ateam_id");
//echo "<META HTTP-EQUIV=\"refresh\" content=\"0;URL=modules.php?name=Campaign&file=CombatAssets\">";
}
echo"<TABLE BORDER=\"0\" WIDTH=\"100%\">"
."<TR>"
."<td width=\"12%\" align=\"right\"><b>Move To Territory: </font></b></td>"
."<td width=\"16%\"><select name=\"tid\" size=\"1\"><option value=\"\">--- Select Territory ---</option>";
//Territory List Box
$result = $db->sql_query("SELECT * FROM " . $prefix . "_eto_territories et
JOIN " . $prefix . "_eto_maps em ON (et.mid = em.mid)
JOIN " . $prefix . "_eto_campaigns ec ON (em.cid = ec.cid)");
//JOIN " . $prefix . "_tc_ladderteams tclt ON (tclt.team_id = '$id')
while ( $row = $db->sql_fetchrow($result) ) {
$t_name = $row["t_name"];
$tid = $row["tid"];
echo "<option value='$tid'>$t_name</option>";
}
echo"</select>"
."</tr>"
."</table>"
."<br>"
."<hr>"
."<input type=\"hidden\" name=\"op\" value=\"Move\">"
."<input type=\"submit\" align=\"center\" name=\"Submit\" value=\"Submit This Move!\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$id\">";
CloseTable();
@include_once("footer.php");
?>
I have not been able to pass the team_id to the Move page. I cannot see the name of the team displayed in the beginning of the page so I know the variable is not getting passed.
<center><H2><strong>Campaign Movement Orders for </strong></H2></center><br>
<center><H2><strong><?php echo $unitname ?></strong></H2></center><br>
The url in the Movement page looks like this.
modules.php?name=Campaign&file=Movement&team_id=10
And the url in the Move page looks like this.
modules.php?name=Campaign&file=Move&team_id=$id
Please help. I am holding everything else up and have a ton of people waiting for me to finish this thing.
I've tried to print $info from the start to see what team_id it contained but it is empty. I don't understand why.