Game Script help
Posted: Tue Aug 30, 2005 9:42 pm
Im making a game and well i came across a few problems all in one
i want to make it where it will check to see if the user has enough gold or money to buy the armor or if i can make it where the radio button will only show when thet user has the same or more money or gold. then make it where it changes the armor, attack, and defense in database. here is my script
armorshop.php
armorshop2.php
Thank you
Smackie
armorshop.php
Code: Select all
<?php
echo'
<center>
<font class="txt">
Armor Shop<br>';
require 'inhandgold.php';
echo'
<br><br>
<font class="txt">
<form name="armor" method="post" action="../index.php?pages=armorshop2">
<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><input name="armor" type="radio" value="sheild"></td>
<td>Sheild</td>
<td>0/5</td>
<td>5 gold</td>
</tr>
<tr>
<td><input name="armor" type="radio" value="leatherhelmet"></td>
<td>Leather Helmet</td>
<td>0/5</td>
<td>10 gold</td>
</tr>
<tr>
<td><input name="armor" type="radio" value="bodyguard"></td>
<td>Body Guard</td>
<td>0/10</td>
<td>25 gold</td>
</tr>
<tr>
<td><input name="armor" type="radio" value="steelarmor"></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>';
?>Code: Select all
<?php
require 'db.php';
$shield = $_POST['shield'];
$leatherhelmet = $_POST['leatherhelmet'];
$bodyguard = $_POST['bodyguard'];
$steelarmor = $_POST['steelarmor'];
$gold = $_GET['gold'];
if (($shield) > ($gold)) {
echo '<center><font size="1" face="tahoma" color="red"><b>Error!</b> Sorry You dont got the Gold for this Armor.</font></center><br>';
require 'armorshop.php';
return;
}
if (($letherhelmet) > ($gold)) {
echo '<center><font size="1" face="tahoma" color="red"><b>Error!</b> Sorry You dont got the Gold for this Armor.</font></center><br>';
require 'armorshop.php';
return;
}
if (($bodyguard) > ($gold)) {
echo '<center><font size="1" face="tahoma" color="red"><b>Error!</b> Sorry You dont got the Gold for this Armor.</font></center><br>';
require 'armorshop.php';
return;
}
if ((steelarmor) > ($gold)) {
echo '<center><font size="1" face="tahoma" color="red"><b>Error!</b> Sorry You dont got the Gold for this Armor.</font></center><br>';
require 'armorshop.php';
return;
}
if ((!$shield) || (!$leatherhelmet) || (!$bodyguard) || (!$steelarmor)) {
echo '<center><font size="1" face="tahoma" color="red"><b>Error!</b> Sorry you dont have enough gold for this armor</font></center><br>';
require 'armorshop.php';
return;
}
$sql = mysql_query("INSERT INTO users (armor)
VALUES('$armor')") 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>';
}
?>Smackie