Path: C:\
<?php
date_default_timezone_set('America/Sao_Paulo');
$dateadded = date("d-m-Y G:i");
session_start();
include_once("../seguranca.php");
include_once("../conexao.php");
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
</head>
<body>
<?php
$result_usuario = "SELECT id FROM usuarios WHERE login='". $_POST["usuario"] ."'";
$resultado_usuario = sqlsrv_query($conn2, $result_usuario);
if(sqlsrv_rows_affected($resultado_usuario) != 0){
echo "
<META HTTP-EQUIV=REFRESH CONTENT = '0;URL=http://localhost/brainfarma/main.php?link=1'>
<script type=\"text/javascript\">
alert(\"Nome de usuário já esta sendo usado. Escolha outro.\");
</script>
";
} else {
$nome = $_POST["nome"];
$email = $_POST["email"];
$usuario = $_POST["usuario"];
$senha = $_POST["senha"];
$nivel_de_acesso = $_POST["nivel_de_acesso"];
$query = sqlsrv_query($conn2,"INSERT INTO [dbo].[usuarios] ([nome],[email],[login],[senha],[nivel_acesso_id],[created]) VALUES (
'" . $nome . "' ,
'" . $email. "' ,
'" . $usuario . "' ,
'" . $senha . "' ,
'" . $nivel_de_acesso . "',
'" . $dateadded. "')" );
if(sqlsrv_rows_affected($query) != 0){
echo "
<script type=\"text/javascript\">
alert(\"Usuário Cadastrado com Sucesso.\");
</script>
";
}
else{
echo "
<script type=\"text/javascript\">
alert(\"Cadastro NÃO teve Sucesso.\");
</script>
";
}}
echo "<script language='JavaScript'>window.location.href='../main.php?link=2'; </script>"
?>
</body>
</html>