(armorpage.php should be fine its armorpage2 thats the problem)
Armorpage.php
Code: Select all
<center>
<?php
include 'db.php';
$sql = mysql_query("SELECT * FROM users WHERE user_name = '".$_SESSION['user_name']."'");
while ($row = mysql_fetch_array($sql)) {
if (($_SESSION['user_level'] == 1) || ($_SESSION['user_level'] == 2) || ($_SESSION['user_level'] == 3) || ($_SESSION['user_level'] == 4) || ($_SESSION['user_level'] == 5)) {
echo '<font class="txt">You have Gold: '. $row["gold"] .' and Money '. $row["money"] .'</font>';
}
}
?>
<?php
include 'db.php';
$sql = mysql_query("SELECT * FROM users WHERE user_name = '".$_SESSION['user_name']."'");
while ($row = mysql_fetch_array($sql)) {
?>
<br><br>
<font class="txt">
<form name="armor" method="post" action="armorshop2.php">
<table width="317" border="1" cellpadding="0" cellspacing="0" class="txt">
<tr>
<td width="21"></td>
<td width="123">Armor Name</td>
<td width="60">Att/Def</td>
<td width="113">Cost</td>
</tr>
<tr>
<td><?php
include 'db.php';
$gold = $row['gold'];
if ($gold >= 50) {
echo'<input name="armor" type="radio" value="shield">';
}else{
echo ' ';
}
?></td>
<td>Shield</td>
<td>0/5</td>
<td>5 gold</td>
</tr>
<tr>
<td><?php
include 'db.php';
$gold = $row['gold'];
if ($gold >= 100) {
echo '<input name="armor" type="radio" value="leatherhelmet">';
}else{
echo' ';
}
?></td>
<td>Leather Helmet</td>
<td>0/5</td>
<td>10 gold</td>
</tr>
<tr>
<td><?php
include 'db.php';
$gold = $row['gold'];
if ($gold >= 100) {
echo '<input name="armor" type="radio" value="bodyguard">';
}else{
echo' ';
}
?></td>
<td>Body Guard</td>
<td>0/10</td>
<td>25 gold</td>
</tr>
<tr>
<td><?php
include 'db.php';
$gold = $row['gold'];
if ($gold >= 100) {
echo '<input name="armor" type="radio" value="steelarmor">';
}else{
echo' ';
}
?></td>
<td>Steel Armor</td>
<td>0/25</td>
<td>50 gold</td>
</tr>
</table>
<table width="317" border="1" cellpadding="0" cellspacing="0" class="txt">
<tr>
<td><center><input name="armor" type="submit" value="Buy Armor" class="submit-button"></center></td>
</tr>
</form>
</font>
</center>
<?php
}
?>Code: Select all
<?php
include 'db.php';
$armor = $_POST['armor'];
$total = $gold - $_POST['gold'];
$sql = mysql_query("UPDATE users ($armor, $total)
VALUES('armor, total')") or die (mysql_error());
if (!$sql) {
echo '<center><font class="h">There has been an error adding your armor. Please contact the webmaster.</font></center>';
}
?>Raven-floft