Файл: vitaliy_nosov/public_html/game/pets/name.php
Строк: 33
<?php
require ('../../config/func.php');
$title = 'Кличка питомца';
require ('../../config/header.php');
auth();
$pets = mysql_query("SELECT * FROM `pets_user` WHERE `user`='".$user['id']."'");
if(mysql_num_rows($pets) == '0'){
echo ' <div class="block center"> У Вас нет питомца</div>';
}else{
$mypets = mysql_fetch_assoc(mysql_query("SELECT * FROM `pets_user` WHERE `user` = '".$user['id']."'"));
}
if(isset($_POST['name'])){
$name = text($_POST['name']);
if(empty($name)) $err = 'Введите кличку';
if($mypets['name'] == $name) $err = 'Ошибка, такая кличка уже была установлена ранее';
if($user['gold'] < 100) $err = 'Нужно 100 <img src="/style/gold.png"> золота';
if(!isset($err)){
mysql_query("update `pets_user` set `name` = '".$name."' where `id` = '".$mypets['id']."'");
mysql_query("update `user` set `gold` = '".($user['gold'] - 100)."' where `id` = '".$user['id']."'");
$_SESSION['notif'] = 'Кличка питомца успешно изменена на «'.$name.'»';
header('Location: ?');
exit;
}else{
$_SESSION['notif'] = $err;
header('Location: ?');
exit;
}
}
?><div class="block">Стоимость новой клички 100 <img src="/style/gold.png"> золота</div><form class="block center" action="" method="post"><br/>
Кличка питомца:</br>
<input type="text" name="name" maxlength="50" value="<?=$mypets['name'];?>"/><br/><input type="submit" class="button_on" value="Изменить"></form><div class="list"><li><a href="/my_pets/"><img src="/style/home.png"> Питомец</a></li></div><?
require ('../../config/footer.php');
?>