Просмотр файла training.php

Размер файла: 2.39Kb
<?
session_start(); //инициализирум механизм сесссий
include 'include/stat.php';
if (!isset($_SESSION['id']))
{
header ("location: logout.php");
exit('incorrect');
}
include 'include/sys.php';
include 'include/game.php';

//параметры игрока
$res = mysql_fetch_assoc(count_query("SELECT * FROM user WHERE id = '".$_SESSION['id']."'"));

$pow_cost=training_cost($res['ab_pow'],'pow');
$def_cost=training_cost($res['ab_def'],'def');
$agi_cost=training_cost($res['ab_agi'],'agi');
$stam_cost=training_cost($res['ab_stam'],'stam');
$chr_cost=training_cost($res['ab_chr'],'chr');


if ($_GET['b']==1 && $res['gold']>=$pow_cost){count_query("UPDATE user SET  ab_pow=ab_pow+1, gold=gold-'$pow_cost' WHERE id = '".$_SESSION['id']."'"); Header("Location: training.php"); exit;};
if ($_GET['b']==2 && $res['gold']>=$def_cost){count_query("UPDATE user SET  ab_def=ab_def+1, gold=gold-'$def_cost' WHERE id = '".$_SESSION['id']."'");Header("Location: training.php"); exit;};
if ($_GET['b']==3 && $res['gold']>=$agi_cost){count_query("UPDATE user SET  ab_agi=ab_agi+1, gold=gold-'$agi_cost' WHERE id = '".$_SESSION['id']."'");Header("Location: training.php"); exit;};
if ($_GET['b']==4 && $res['gold']>=$stam_cost){count_query("UPDATE user SET  ab_stam=ab_stam+1, gold=gold-'$stam_cost' WHERE id = '".$_SESSION['id']."'");Header("Location: training.php"); exit;};
if ($_GET['b']==5 && $res['gold']>=$chr_cost){count_query("UPDATE user SET  ab_chr=ab_chr+1, gold=gold-'$chr_cost' WHERE id = '".$_SESSION['id']."'");Header("Location: training.php"); exit;};




$sum=$res['ab_pow']+$res['ab_def']+$res['ab_agi']+$res['ab_stam']+$res['ab_chr']; //сумма всех статов для расчета линий
?>


<?include 'include/head.php';?>


<div class="link"><a href="main.php">Обзор</a> | Тренировка </div>
Здесь Вы можете улучшить способности, чтобы успешно сокрушить своих врагов.
<div class="in">Тренировка</div>
Золото: <?=$res['gold'];?>
<br>Сила:<?=$res['ab_pow'];?> <a href="training.php?b=1">стоимость <?=$pow_cost;?></a></br>Защита:<?=$res['ab_def'];?> <a href="training.php?b=2">стоимость <?=$def_cost;?></a></br>Ловкость:<?=$res['ab_agi'];?> <a href="training.php?b=3">стоимость <?=$agi_cost;?></a></br>Выносливость:<?=$res['ab_stam'];?> <a href="training.php?b=4">стоимость <?=$stam_cost;?></a></br>Харизма:<?=$res['ab_chr'];?> <a href="training.php?b=5">стоимость <?=$chr_cost;?></a>


<?include 'include/foot.php';?>