initial commit
This commit is contained in:
39
setup/setup.php
Normal file
39
setup/setup.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
if(session_status() !== PHP_SESSION_ACTIVE){
|
||||
session_start();
|
||||
}
|
||||
|
||||
include('../conexao_publica.php');
|
||||
|
||||
$usuario = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
|
||||
$senha = filter_input(INPUT_POST, 'passwd', FILTER_SANITIZE_STRING);
|
||||
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_STRING);
|
||||
|
||||
$empty = 'vazio';
|
||||
$nome = 'Administrador';
|
||||
$tipo='adm';
|
||||
|
||||
$sql = "INSERT INTO tbclientes (nome, endereco, bairro, cidade, estado, email, cpf_cnpj, rg) VALUES (?,?,?,?,?,?,?,?)";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bind_param('ssssssss',$nome,$empty,$empty,$empty,$empty,$email,$empty,$empty);
|
||||
|
||||
if($stmt->execute())
|
||||
{
|
||||
$id=$stmt->insert_id;
|
||||
$stmt->close();
|
||||
$sql = "INSERT INTO login_usuarios (login,senha,tipo,id_cliente) VALUES(?,?,?,?)";
|
||||
$hashed = password_hash($senha,PASSWORD_DEFAULT);
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bind_param('ssss',$usuario,$hashed,$tipo,$id);
|
||||
if($stmt->execute())
|
||||
{
|
||||
$_SESSION['msg'] = "Configurado com sucess, por favor faça o login!";
|
||||
unset($_SESSION['setup']);
|
||||
}
|
||||
else{
|
||||
$_SESSION['msg'] = "Erro no cadastro!";
|
||||
}
|
||||
$stmt->close();
|
||||
header('Location: ../index.php');
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user