<?
if(empty($act)) {
$uner = @mysql_query("SELECT * FROM `medal` WHERE user='".$nick."';");
$ter_uner = @mysql_fetch_array($uner);
$select = @mysql_query ("Select * from users where id='".$nick."'");
$inf = mysql_fetch_array ($select);

if($wap==2||$wap==3){
echo "<form action=\"adminka.php?$ses$takep&amp;go=medal&amp;nick=$nick\" method=\"post\">";
echo $fs1;
echo "Медаль:<br/>";
echo $fs2;
echo "<select name=\"medal\">";
if($inf["medal"] === "0")
{
echo "<option value=\"0\">Нет</option>";
}
elseif($inf["medal"] === "1")
{
echo "<option value=\"1\">Бронзовая</option>";
}
elseif($inf["medal"] === "2")
{
echo "<option value=\"2\">Серебренная</option>";
}
elseif($inf["medal"] === "3")
{
echo "<option value=\"3\">Золотая</option>";
}
echo "<option value=\"0\">Нет</option>";
echo "<option value=\"1\">Бронзовая</option>";
echo "<option value=\"2\">Серебренная</option>";
echo "<option value=\"3\">Золотая</option>";
echo "</select><br/>";
echo "$fs1 За:<br />$fs2<input type=\"text\" value=\"".$ter_uner['prich']."\"  name=\"prich\"\" maxlength=\"500\" /><br />";
echo "<input type=\"hidden\" name=\"act\" value=\"add\"/><input class=\"ibutton\" type=\"submit\" value=\"Вручить\"/></form>";
}else{
echo $fs1;
echo "Медаль:<br/>";
echo $fs2;
echo "<select name=\"medal\">";
echo "<option value=\"1\">Бронзовая</option>";
echo "<option value=\"2\">Серебреная</option>";
echo "<option value=\"3\">Золотая</option>";
echo "</select><br/>";
echo "$fs1 За:<br />$fs2<input type=\"text\" value=\"".$ter_uner['prich']."\"  name=\"prich\"\" maxlength=\"500\" /><br />";
echo "<anchor>Вручить<go href=\"adminka.php?$ses$takep&amp;go=medal&amp;nick=$nick\" method=\"post\">
<postfield name=\"medal\" value=\"$(medal)\"/>
<postfield name=\"prich\" value=\"$(prich)\"/>
<postfield name=\"act\" value=\"add\"/>
</go></anchor><br/><br />";
}
}else{

$prich = check($prich);
$date = date("d-m-y");
$prow_pr = @mysql_query("SELECT * FROM `medal` WHERE user='".$nick."';");
if(@mysql_num_rows($prow_pr) != 0){

if((@mysql_query("update `medal` set medal='".$medal."', prich='".$prich."' WHERE user='".$nick."';"))){
mysql_query("UPDATE `users` SET `medal` = '".$medal."' WHERE `id` = '".$nick."' LIMIT 1");
echo "Медаль вручена!<br/>";
}else{
echo "Произошла ошибка!<br />";
}
}else{
if((@mysql_query("insert into medal values(0,'".$nick."','".$medal."','".$row['id']."','".$prich."','".$date."');"))){
mysql_query("UPDATE `users` SET `medal` = '".$medal."' WHERE `id` = '".$nick."' LIMIT 1");
echo "Медаль вручена!<br /><br/>";
}else{
echo 'Произошла ошибка!<br />';}
}
}

?>