I have a game script I am trying to develop. I have attacking teams and defending teams, each with their own team_id. Only attacking teams use the Attack.php page, so I capture that team_id as ateam_id.
I have some functions that check their current status and whether or not they are allowed to attack.
The problem is that the values I gather do not get sent to the database.
I capture the attacking team when I enter the page.
$ateam_id = $_GET['team_id'];
as team_id is passed from the previous page.
My CURRENT_TIMESTAMP() and the $action are all that get written to the table.
I have not been able to capture the following
ateam_id - Attacking Team
dteam_id - Defending Team
tid - Current Territory.
The following is an example. I am the 4th Infantry as the attacking team and I have 1st Special Forces and UK Hitlers Assasins as Defending teams. I could choose either one to attack.

My query seems correct as it displays exactly what I want. Defending team is listed as well as the territory.
$sql = $db->sql_query("SELECT * FROM " . $prefix . "_tc_teams tct JOIN " . $prefix . "_eto_territories et WHERE tct.tid = '$tid' AND et.tid = '$tid' AND div_id != '$div_id'");
while ( $row = $db->sql_fetchrow($sql) ) {
$dteam_id = $row['team_id'];
$dteam_name = $row['name'];
$tid = $row['tid'];
$territory = $row['t_name'];
echo "<tr>"
."<td align=\"center\" bgcolor=\"#666666\"><font color=\"#000000\">$dteam_id</font>"
. "<input type=\"hidden\" name=\"ateam_id\" value=\"$ateam_id\">"
. "<input type=\"hidden\" name=\"dteam_id\" value=\"$dteam_id\">"
. "<input type=\"hidden\" name=\"tid\" value=\"$tid\">"
. "<input type=\"hidden\" name=\"div_id\" value=\"$div_id\">"
. "<input type=\"hidden\" name=\"op\" value=\"ConfirmAttack\"></td>"
. "<td align=\"center\" bgcolor=\"#666666\"><font color=\"#000000\">$dteam_name</font></td>"
. "<td align=\"center\" bgcolor=\"#666666\"><font color=\"#000000\">$territory</font></td>"
. "<td align=\"center\" bgcolor=\"#666666\"><font color=\"#000000\">[ <a href=\"modules.php?name=Campaign&file=Attack&op=ConfirmAttack&team_id=$dteam_id\">" . _CLICK . "</a>]</td>"
. "</tr>";
}
My confirmAttack is as follows:
if ($op == "ConfirmAttack") {
$ateam_id = $_POST['team_id'];
$dteam_id = $_POST['dteam_id'];
$tid = $_POST['tid'];
$action = 'Attack';
$result = $db->sql_query ("INSERT INTO " . $prefix . "_eto_tracking (log_id, ateam_id, dteam_id, tid, move_dt, action)".
"VALUES (NULL,'$ateam_id','$dteam_id','$tid',CURRENT_TIMESTAMP(),'$action')");
if (!$result) {
echo("<p><font color=RED size=6><center>Error performing attack. Data has not been sent!</center></font></p>");
}else{
echo "<P><font color=RED size=5><center>Attack Orders Have Been Sent!</center></font></p>";
}
}
I added
print_r($_POST);
die();
after $action = 'Attack'; to see what _POST contained and get Array() returned which I assume is empty.
I have struggled with this and had several eyes other than mine take a look and am at the end of my rope.
Here is the code in its entirety:
<?php
session_start();
if(!session_is_registered(commanderloggedin)){
Header("Location: modules.php?name=Campaign&file=checkcommander");
}
/************************************************************************/
/* ETO Campaign Mod */
/* Author::Donovan [3rd ID] */
/* Copyright (c) 2005 by Steven Donovan AKA Donovan [3rd ID] */
/* Email:: donovan@3rd-infantry-division.net
/* Homepage::http://www.eto-league.com */
/*
/************************************************************************/
// Attack Form
###############################################################
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
global $db, $prefix, $module_name, $admin_file;
include_once("header.php");
define('INDEX_FILE', true);
$index = 1;
include_once("modules/$module_name/common.php");
$ateam_id = $_GET['team_id'];
$sql = "SELECT name FROM " . $prefix . "_tc_teams WHERE team_id ='$ateam_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'];
}
if ($op == "ConfirmAttack") {
$ateam_id = $_POST['team_id'];
$dteam_id = $_POST['dteam_id'];
$tid = $_POST['tid'];
$action = 'Attack';
$result = $db->sql_query ("INSERT INTO " . $prefix . "_eto_tracking (log_id, ateam_id, dteam_id, tid, move_dt, action)".
"VALUES (NULL,'$ateam_id','$dteam_id','$tid',CURRENT_TIMESTAMP(),'$action')");
if (!$result) {
echo("<p><font color=RED size=6><center>Error performing attack. Data has not been sent!</center></font></p>");
}else{
echo "<P><font color=RED size=5><center>Attack Orders Have Been Sent!</center></font></p>";
}
}
$verify = checkstatus($team_id);
if ($verify) {
exit();
}
$sql1 = "SELECT tid FROM " . $prefix . "_tc_teams WHERE team_id ='$ateam_id'";
$result1 = $db->sql_query($sql1);
$info1 = $db->sql_fetchrow($result1);
$tid = $info1['tid'];
$enemy = checkmove($tid, $team_id);
if (!$enemy) {
OpenTable();
echo"<center><h3><b>" . _ATTACKTEAMS. "</b></h3></center><br><br>"
."<center><b><font color=RED size=4> There are no enemy forces positioned on your territory! </font></b></center><br><br>"
."<center><b> Your team is not in a position to attack at this time! </b></center><br><br>"
."<center><b> Move your team to a territory and engage enemy forces! </b></center><br><br>"
."<br>";
CloseTable();
include('footer.php');
}else{
$sql = "SELECT div_id FROM " . $prefix . "_tc_teams WHERE team_id ='$ateam_id'";
$result = $db->sql_query($sql);
$mydiv = $db->sql_fetchrow($result);
$div_id = $mydiv['div_id'];
OpenTable();
echo "<form name=\"Attack\" action=\"modules.php?name=Campaign&op=ConfirmAttack\" method=\"POST\">";
echo"<center><H3><strong>$unitname</strong></H3></center><br>";
echo"<center><H3><strong>Has made contact against enemy forces!</strong></H3></center><br>"
."<br>"
."<center><H3><b> Enemy forces are positioned on your territory! </b></H3></center><br><br>";
echo "<br>";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"3\">"
."<tr>"
."<th width=\"5%\">"._ID."</th>"
."<th width=\"20%\">"._ENEMY."</th>"
."<th width=\"20%\"><b>"._TERRNAME."</b></th>"
."<th width=\"20%\">"._ATTACK."</th>"
."</tr>";
$sql = $db->sql_query("SELECT * FROM " . $prefix . "_tc_teams tct JOIN " . $prefix . "_eto_territories et WHERE tct.tid = '$tid' AND et.tid = '$tid' AND div_id != '$div_id'");
while ( $row = $db->sql_fetchrow($sql) ) {
$dteam_id = $row['team_id'];
$dteam_name = $row['name'];
$tid = $row['tid'];
$territory = $row['t_name'];
echo "<tr>"
."<td align=\"center\" bgcolor=\"#666666\"><font color=\"#000000\">$dteam_id</font>"
. "<input type=\"hidden\" name=\"ateam_id\" value=\"$ateam_id\">"
. "<input type=\"hidden\" name=\"dteam_id\" value=\"$dteam_id\">"
. "<input type=\"hidden\" name=\"tid\" value=\"$tid\">"
. "<input type=\"hidden\" name=\"div_id\" value=\"$div_id\">"
. "<input type=\"hidden\" name=\"op\" value=\"ConfirmAttack\"></td>"
. "<td align=\"center\" bgcolor=\"#666666\"><font color=\"#000000\">$dteam_name</font></td>"
. "<td align=\"center\" bgcolor=\"#666666\"><font color=\"#000000\">$territory</font></td>"
. "<td align=\"center\" bgcolor=\"#666666\"><font color=\"#000000\">[ <a href=\"modules.php?name=Campaign&file=Attack&op=ConfirmAttack&team_id=$dteam_id\">" . _CLICK . "</a>]</td>"
. "</tr>";
}
echo "</table>";
echo "</form>";
CloseTable();
}
@include_once("footer.php");
?>
Can anybody see anything at all. I am way behind schedule in getting this working.