Hello everyone, this is my first post on this forum, and I hope it is a worthwhile one. I have come here in hopes to fix this code. Can anyone see why it isn't working?
<? include_once("header.php");
require_login(); ?>
<center>
<table>
<form method="POST" action="buildings.php">
<tr>
<td width="10%">Gold Mine</td><td width="10%">250</td><td width="10%">175</td><td width="10%">200</td><td width="10%">50
</td><td width="10%"><input name="strGoldmines" type="text"></tr>
<tr>
<td width="10%">Lumber Mill</td><td width="10%">225</td><td width="10%">100</td><td width="10%">150</td><td width="10%">75
</td><td width="10%"><input name="strLumbermills" type="text"></tr>
<tr>
<td width="10%">Steel Forge</td><td width="10%">300</td><td width="10%">175</td><td width="10%">75</td><td width="10%">100
</td><td width="10%"><input name="strSteelforges" type="text"></tr>
<tr>
<td width="10%">Stone Quarry</td><td width="10%">275</td><td width="10%">200</td><td width="10%">150</td><td width="10%">75
</td><td width="10%"><input name="strStonequarries" type="text"></tr>
<tr>
<td width="10%">Farm</td><td width="10%">200</td><td width="10%">200</td><td width="10%">125</td><td width="10%">100
</td><td width="10%"><input name="strFarms" type="text"></tr>
</table>
<table cellspacing="0" cellpadding="4" border="0" align="center" bgcolor="#000000">
<tr><td colspan="5" align="center">To Build/Deconstruct:</td>
<tr><td align="center"><input name="building" type="submit" value="Build" align="center">
<input type="submit" name="destroy" value="Demolish" align="center"></td></tr>
</form>
</table>
</center>
<?
$id = $_SESSION[MEMBERID];
$result = $DB->fetch("SELECT u.username, g.gold, g.wood, g.steel, g.stone, g.food, g.goldmines, g.lumbermills, g.steelforges, g.stonequarries, g.farms FROM gamedata g LEFT JOIN users u ON u.id = g.id WHERE g.id ='$id'");
$username = $result[username];
$gold = $result[gold];
$wood = $result[wood];
$steel = $result[steel];
$stone = $result[stone];
$food = $result[food];
$goldmines = $result[goldmines];
$lumbermills = $result[lumbermills];
$steelforges = $result[steelforges];
$stonequarries = $result[stonequarries];
$farms = $result[farms];
echo "Username: $username";
echo "<br /><br /><h3>Buildings</h3>";
echo "<br />Gold Mines: $goldmines";
echo "<br />Lumber Mills: $lumbermills";
echo "<br />Steel Forges: $steelforges";
echo "<br />Stone Quarries: $stonequarries";
echo "<br />Farms: $farms";
function make_building($build,$total)
{
if($building == "strGoldmines") return "mines";
if($building == "strLumbermills") return "mills";
if($building == "strSteelforges") return "forges";
if($building == "strStonequarries") return "quarries";
if($building == "strFarms") return 'farms';
}
$gold = $total;
$wood = $total;
$steel = $total;
$stone = $total;
switch($building)
{
case "strGoldmines":
$gold = 250; $wood = 175; $steel = 200; $stone = 50; break;
case "strLumbermills":
$gold = 225; $wood = 100; $steel = 150; $stone = 75; break;
case "strSteelforges":
$gold = 300; $wood = 175; $steel = 75; $stone = 100; break;
case "strStonequarries":
$gold = 275; $wood = 200; $steel = 150; $stone = 75; break;
case "strFarms":
$gold = 200; $wood = 200; $steel = 125; $stone = 100; break;
}
$update = $DB->query("UPDATE gamedata SET gold=gold-'$gold', wood=wood-'$wood', steel=steel-'$steel', stone=stone-'$stone', goldmines=goldmines+'$total', lumbermills=lumbermills+'$total', steelforges=steelforges+'$total', stonequarries=stonequarries+'$total', farms=farms+'$total' WHERE id ='$id'");
if($update)
{
echo "Buildings Created!";
}
elseif (!isset($POST[strGoldmines]) || !isset($POST[strLumbermills]) || !isset($POST[strSteelforges]) || !isset($POST[strStonequarries]) || !isset($_POST[strFarms]))
{
echo "Please enter number of buildings to build.";
}
else
{
echo "Unknown Error, try again.";
}
?>
<? include_once("footer.php"); ?>