-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcadastrar.php
63 lines (38 loc) · 1.54 KB
/
cadastrar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
require_once("conexao.php");
$tabela = 'empresas';
$data_hoje = date('Y-m-d');
$email = $_POST['email'];
$nome = $_POST['nome'];
$senha = $_POST['senha'];
$telefone = $_POST['telefone'];
$query = $pdo->query("SELECT * FROM config WHERE empresa = 0");
$res = $query->fetchAll(PDO::FETCH_ASSOC);
$total_reg = @count($res);
$teste_config = $res[0]['teste'];
$dias_teste = $res[0]['dias_teste'];
if($dias_teste == ""){
$dias_teste = 3;
}
$senha_crip = md5($senha);
$data_pgto = date('Y-m-d', strtotime("+$dias_teste days",strtotime($data_hoje)));
//validar nome
$query = $pdo->query("SELECT * from $tabela where email = '$email'");
$res = $query->fetchAll(PDO::FETCH_ASSOC);
if(@count($res) > 0){
echo 'Email já Cadastrado, escolha outro!!';
exit();
}
$query = $pdo->prepare("INSERT into $tabela SET nome = :nome, email = :email, telefone = :telefone, ativo = 'Sim', data_cad = curDate(), data_pgto = '$data_pgto', valor = '0', teste = 'Sim' ");
$query->bindValue(":nome", "$nome");
$query->bindValue(":email", "$email");
$query->bindValue(":telefone", "$telefone");
$query->execute();
$id_empresa = $pdo->lastInsertId();
$query = $pdo->prepare("INSERT into usuarios SET empresa = '$id_empresa', nome = :nome, email = :email, telefone = :telefone, senha = '$senha', senha_crip = '$senha_crip', ativo = 'Sim', foto = 'sem-foto.jpg', nivel = 'Administrador', data = curDate() ");
$query->bindValue(":nome", "$nome");
$query->bindValue(":email", "$email");
$query->bindValue(":telefone", "$telefone");
$query->execute();
echo 'Salvo com Sucesso';
?>