<?php
	if($_SESSION['nivel'] == 1){
?>
	<meta http-equiv="refresh" content="5; url=miolo.php?miolo=usuarios&acao=gerenciar" />
<?

	if(!empty($_POST['emailUser']) && !empty($_POST['login'])){
		$selectLogin = mysql_query("SELECT COUNT(id) FROM usuarios WHERE login = '".$_POST['login']."' AND id <> '".$_POST['idUser']."'");
		$qtdLogin = mysql_result($selectLogin, 0,0);
		if($qtdLogin == 0){
			$result=mysql_query("UPDATE usuarios SET nomeUser = '".$_POST['nomeUser']."', emailUser = '".$_POST['emailUser']."', nivelUser = '".$_POST['nivelUser']."', login = '".$_POST['login']."', senha = '".sha1($_POST['senha'])."' WHERE id = '".$_POST['idUser']."' ") or die (mysql_error());
			if($result){
				?>
				<p align="center" style="margin-top:100"><font color="#000066" face="Arial, Helvetica, sans-serif" size="+2"> Dados atualizados com sucesso</font></p>
				<?
			}
		}

		if($qtdLogin > 0){
			?>
				<p align="center" style="margin-top:100"><font color="#000066" face="Arial, Helvetica, sans-serif" size="+2"> J&aacute; existe usu&aacute; com esse login.</font></p>
			<?
		}
	}
	if(empty($_POST['emailUser']) || empty($_POST['login'])){
		?>
			<p align="center" style="margin-top:100"><font color="#000066" face="Arial, Helvetica, sans-serif" size="+2"> Informe pelo menos o email e o login do usu&aacute;rio.</font></p>
		<?	
	}
}
?>

