Code: Select all
//user buys unit gunmen//
if(isset($_POST['train'])){
$henchmen = protect($_POST['henchmen']);
$food_needed = (30 * $henchmen);
if($henchmen < 1){
echo '<span id="errormess"><big><font color="red"><b>You must train a positive number of units!</b></font></span></big>';
}elseif($stats['food'] < $food_needed){
echo '<span id="errormess"><big><font color="red"><b>You do not have enough food!</b></font></span></big>';
}else{
$unit['henchmen'] += $henchmen;
$update_business = mysql_query("UPDATE `unit` SET `henchmen`='".$unit['henchmen']."' WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error());
$stats['food'] -= $food_needed;
$update_food = mysql_query("UPDATE `stats` SET `food`='".$stats['food']."' WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error());
echo '<span id="errormess"><big><font color="red"><b>You have trained your units!</b></font></span></big>';
}
}
//user buys unit guards//
if(isset($_POST['train'])){
$guards = protect($_POST['guards']);
$food_needed = (30 * $guards);
if($guards == 0){
echo '<span id="errormess"><big><font color="red"><b>You must train a positive number of units!</b></font></span></big>';
}elseif($stats['food'] < $food_needed){
echo '<span id="errormess"><big><font color="red"><b>You do not have enough food!</b></font></span></big>';
}else{
$unit['guards'] += $guards;
$update_business = mysql_query("UPDATE `unit` SET `guards`='".$unit['guards']."' WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error());
$stats['food'] -= $food_needed;
$update_food = mysql_query("UPDATE `stats` SET `food`='".$stats['food']."' WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error());
echo '<span id="errormess"><big><font color="red"><b>You have trained your units!</b></font></span></big>';
}
}Code: Select all
You must train a positive number of units!