<?php
session_start();
include_once "../inc/db_connect.php";
header('Content-Type: text/html;charset=utf8');
$err = "";
if(isset($_POST['regok'])){unset($_SESSION['reg_ok']);}
if(!isset($_SESSION['user'])){
	header("Location: index.php?");
	exit();
}else{
	$data_user = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE nick='".$_SESSION['user']."'")) or die(mysql_error());
	if($data_user['status'] == "Гонщик"){
		header("Location: ../index.php?");
		exit();
	}else{
?>
<?php
if($data_user['status'] == "Создатель"){
if(isset($_POST['submitsoz'])){
	$idp = mysql_real_escape_string($_POST['id1']);
	$nickp = mysql_real_escape_string($_POST['nick1']);
	$passwordp = mysql_real_escape_string($_POST['pass1']);
	$statusp = mysql_real_escape_string($_POST['status1']);
	$fuelp = mysql_real_escape_string($_POST['fuel1']);
	$speedp = mysql_real_escape_string($_POST['speed1']);
	$levelp = mysql_real_escape_string($_POST['level1']);
	$moneyp = mysql_real_escape_string($_POST['money1']);
	$moneyp2 = mysql_real_escape_string($_POST['money12']);
	$opitp = mysql_real_escape_string($_POST['opit1']);
	$carp = mysql_real_escape_string(trim($_POST['car1']));
	$carnamep = mysql_real_escape_string($_POST['carname1']);
	$raitingp = mysql_real_escape_string(strip_tags(stripslashes(htmlspecialchars($_POST['raiting1']))));
		$editok1 = mysql_query("UPDATE users SET `nick`='$nickp',`password`='$passwordp',`status`='$statusp',`fuel`='$fuelp',`speed`='$speedp',`level`='$levelp',`money`='$moneyp',`money2`='$moneyp2',`opit`='$opitp',`car`='$carp',`carname`='$carnamep',`raiting`='$raitingp' WHERE id='".$idp."'") or die(mysql_error());
		if($editok1 == true){
			echo "<meta http-equiv='refresh' content='0; URL=index.php?users' />";
			exit();
	}
}
else{
	echo "<meta http-equiv='refresh' content='0; URL=index.php?users' />";
	exit();
}
}elseif($data_user['status'] == "Админ"){
if(isset($_POST['submitadm'])){
	$idp2 = mysql_real_escape_string($_POST['id3']);
	if($idp2 == 1){
		echo "<meta http-equiv='refresh' content='0; URL=index.php?' />";
		exit();
	}else{
	$statusp2 = mysql_real_escape_string($_POST['status3']);
		$editok2 = mysql_query("UPDATE users SET `status`='$statusp2' WHERE id='".$idp2."'") or die(mysql_error());
		if($editok2 == true){
			echo "<meta http-equiv='refresh' content='0; URL=index.php?users' />";
			exit();
	}
}
}
else{
	echo "<meta http-equiv='refresh' content='0; URL=index.php?users' />";
	exit();
}
}elseif($data_user['status'] == "Модератор"){
if(isset($_POST['submitmod'])){
		echo "<meta http-equiv='refresh' content='0; URL=index.php?users' />";
		exit();
	}
else{
	echo "<meta http-equiv='refresh' content='0; URL=index.php?users' />";
	exit();
}
}else{
	echo "<meta http-equiv='refresh' content='0; URL=../index.php' />";
	exit();
}
?>
<?
}
}
?>