i made this script but when i add some text into the textbox then click buy it inserts nothing into the database when i want it to insert tge number entered into the textbox.
PHP Code:
<?php
include("**");
include("**");
?>
<?php
if ($action == 'buy')
{
$weapon11 = $_POST['weapon1'];
$weapon111 = $weapon11;
$sql = mysql_query ("UPDATE `user_weapons` SET `Machine Gun` = '$weapon111' WHERE `username` = '$session->username' LIMIT 1");
mysql_query($sql);
}
?>
<html>
<head>
<title>ARMORY</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p><strong><font size="7">Armory</font></strong></p>
<p><?php
$resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1");
$row2 = mysql_fetch_row($resultconfig2);
$cash3 = $row2['0'];
$cash4 = number_format($cash3);
echo "You have $cash4 to spend.";
?>
<p>
<table width="62%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="157"><div align="center"><strong>Weapon</strong></div></td>
<td width="76"><div align="center"><strong>Strength</strong></div></td>
<td width="66"><div align="center"><strong>Cost</strong></div></td>
<td width="85"><div align="center"><strong>You Have</strong></div></td>
<td width="56"><div align="center"><strong>Max</strong></div></td>
<td width="36"><div align="center"><strong>Buy </strong></div></td>
</tr>
<tr>
<td>Machine Gun</td>
<td>100</td>
<td>500</td>
<td> </td>
<td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1");
$row2 = mysql_fetch_row($resultconfig2);
$cash3 = $row2['0'];
$totalweapons = ($cash3 / 500) - 1;
$totalweapons2 = number_format($totalweapons);
echo "$totalweapons2";
?>
</td><td width="36"><form name="weapon1" method="post" action="/armory.php?action=buy">
<input name="weapon1" type="text" id="weapon1" size="5">
</form></td>
</tr>
<tr>
<td>EMP Cannon</td>
<td>500</td>
<td>25,000</td>
<td> </td>
<td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1");
$row2 = mysql_fetch_row($resultconfig2);
$cash3 = $row2['0'];
$totalweapons = ($cash3 / 25000) - 1;
$totalweapons2 = number_format($totalweapons);
echo "$totalweapons2";
?></td>
<td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
<input name="weapon2" type="text" id="weapon2" size="5">
</form></td>
</tr>
<tr>
<td>Ion Cannon</td>
<td>900</td>
<td>45,000</td>
<td> </td>
<td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1");
$row2 = mysql_fetch_row($resultconfig2);
$cash3 = $row2['0'];
$totalweapons = ($cash3 / 45000) - 1;
$totalweapons2 = number_format($totalweapons);
echo "$totalweapons2";
?></td>
<td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
<input name="weapon3" type="text" id="weapon3" size="5">
</form></td>
</tr>
<tr>
<td>Molecular Disruptor</td>
<td>2500</td>
<td>125,000</td>
<td> </td>
<td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1");
$row2 = mysql_fetch_row($resultconfig2);
$cash3 = $row2['0'];
$totalweapons = ($cash3 / 125000) - 1;
$totalweapons2 = number_format($totalweapons);
echo "$totalweapons2";
?></td>
<td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
<input name="weapon4" type="text" id="weapon4" size="5">
</form></td>
</tr>
<tr>
<td>Mass Projectile Cannon</td>
<td>5000</td>
<td>250,000</td>
<td> </td>
<td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1");
$row2 = mysql_fetch_row($resultconfig2);
$cash3 = $row2['0'];
$totalweapons = ($cash3 / 250000) - 1;
$totalweapons2 = number_format($totalweapons);
echo "$totalweapons2";
?></td>
<td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
<input name="weapon5" type="text" id="weapon5" size="5">
</form></td>
</tr>
<tr>
<td>Mass Driver Cannon</td>
<td>5500</td>
<td>275,000</td>
<td> </td>
<td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1");
$row2 = mysql_fetch_row($resultconfig2);
$cash3 = $row2['0'];
$totalweapons = ($cash3 / 275000) - 1;
$totalweapons2 = number_format($totalweapons);
echo "$totalweapons2";
?></td>
<td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
<input name="weapon6" type="text" id="weapon6" size="5">
</form></td>
</tr>
<tr>
<td>Special Rift Generator</td>
<td>7000</td>
<td>350,000</td>
<td> </td>
<td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1");
$row2 = mysql_fetch_row($resultconfig2);
$cash3 = $row2['0'];
$totalweapons = ($cash3 / 350000) - 1;
$totalweapons2 = number_format($totalweapons);
echo "$totalweapons2";
?></td>
<td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
<input name="weapon7" type="text" id="weapon7" size="5">
</form></td>
</tr>
<tr>
<td>Cosmic Energy Enhancer</td>
<td>14,000</td>
<td>750,000</td>
<td> </td>
<td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1");
$row2 = mysql_fetch_row($resultconfig2);
$cash3 = $row2['0'];
$totalweapons = ($cash3 / 750000) - 1;
$totalweapons2 = number_format($totalweapons);
echo "$totalweapons2";
?></td>
<td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
<input name="weapon8" type="text" id="weapon8" size="5">
</form></td>
</tr>
<tr>
<td>Nuclear Time Bomb</td>
<td>20,000</td>
<td>1,000,000</td>
<td> </td>
<td width="56"><?php $resultconfig2 = @mysql_query("SELECT `money` FROM `users` WHERE `username` = '$session->username' LIMIT 1");
$row2 = mysql_fetch_row($resultconfig2);
$cash3 = $row2['0'];
$totalweapons = ($cash3 / 1000000) - 1;
$totalweapons2 = number_format($totalweapons);
echo "$totalweapons2";
?></td>
<td width="36"><form name="form1" method="post" action="/armory.php?action=buy">
<input name="weapon9" type="text" id="weapon9" size="5">
</form></td>
</tr>
</table>
<table width="62%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="right">
<form name="form2" method="post" action="/armory.php?action=buy">
<input name="buy" type="submit" id="buy" value="Buy">
</form>
</div></td>
</tr>
</table>
</body>
</html>
|