<?php
$location = true;
require_once($_SERVER['DOCUMENT_ROOT']."/core/func.php");
head("Обменник",$uid);
//
//
if(isset($_REQUEST['ok'])){
$ruby = abs(intval($_POST['ruby']));
$coll = $ruby*1000;
if($user['gold'] < $ruby){
header('location:?err=1');
exit();
}
if($ruby <= 0){
header('location:?err=2');
exit();
}
qry("UPDATE `users` SET `silver` = `silver` + ?, `gold` = `gold` - ? WHERE `id` = ? LIMIT 1", array($coll,$ruby,$uid));
msg2("Обмен прошел успешно");
header('location:?');
exit();
}
//
//
?>
<div class="tophead">
<img src="/images/ruby.png" width="17px" height="17px" alt=""> 1 рубин = <img src="/images/gold.png" width="17px" height="17px" alt=""> 1000 золота<br>
У вас: <img src="/images/ruby.png" width="17px" height="17px" alt=""> <?=$user['gold'];?> рубинов
</div>
<div class="tophead cntr">
Сколько рубинов хотите обменять?
<br>
<form action="" method="post">
<input class="" type="text" name="ruby" maxlength="50" value="" />
<br>
<input type="submit" name="ok" class="" value="Обменять">
</form>
</div>
<a href="/shop.php" class="tophead">Вернуться назад</a>
<?
//
//
foot($uid);
//
//
?>