-
Notifications
You must be signed in to change notification settings - Fork 0
/
createAcc.php
111 lines (103 loc) · 3.78 KB
/
createAcc.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
include('dbconnect.php');
include('utils.php');
$errorMessage = null;
if(isset($_POST['criarConta'])) {
$nomeCriar = $mysqli->real_escape_string($_POST['nomeCriar']);
$emailCriar = $mysqli->real_escape_string($_POST['emailCriar']);
$confirmeEmail = $mysqli->real_escape_string($_POST['confirmeEmail']);
$senhaCriar = $mysqli->real_escape_string($_POST['senhaCriar']);
$senhaCriarHash = password_hash($senhaCriar, PASSWORD_BCRYPT);
$confirmeSenha = $mysqli->real_escape_string($_POST['confirmeSenha']);
if($confirmeEmail != $emailCriar) {
$errorMessage = "E-mails não são iguais";
} else if($confirmeSenha != $senhaCriar) {
$errorMessage = "Senhas não são iguais";
} else {
$sql_codeEmail = "SELECT * FROM usuarios WHERE email = '$emailCriar'";
$sql_queryEmail = $mysqli->query($sql_codeEmail) or die('Falha na execução do SQL: Email query');
$resultQueryEmail = $sql_queryEmail->num_rows;
if($resultQueryEmail >= 1) {
$errorMessage = "Email em uso";
} else {
$sql_codeCriar = "INSERT INTO usuarios (nome, email, senha) VALUES ('$nomeCriar', '$emailCriar', '$senhaCriarHash');";
$sql_queryCriar = $mysqli->query($sql_codeCriar) or die('Falha na execução do SQL: createAcc query');
header("Location: index.php");
}
}
}
?>
<!DOCTYPE html>
<html lang="pt-br">
<title>Criar Conta</title>
<head>
<meta name="viewport" content="width=device-width,initial-scale=0.7,maximum-scale=0.7,user-scalable=no"/>
<link rel="icon" type="image/png" href="favicons/favicon.png">
</head>
<style>
<?php
$css = file_get_contents('css/styles.css');
$fontawesome = file_get_contents('css/all.min.css');
echo $css;
echo $fontawesome;
?>
</style>
<header>
<div class="message">
<a class="textContainer">Olá, seja bem vindo!</a>
</div>
<div class="navbar">
<a class="linkButton" href="index.php">
<i class="fa fa-home"></i>Início
</a>
<a class="linkButton" href="account.php">
<i class="fa fa-user"></i>Conta
</a>
<a class="linkButton" href="logout.php">
<i class="fa fa-sign-out-alt"></i>Sair
</a>
</div>
</header>
<div class="headerSpacer"></div>
<?php if(!is_null($errorMessage)) { customError($errorMessage); }?>
<body>
<form class="form" id="loginForm" action="" method="POST">
<p>Crie sua conta abaixo!</p>
<p>
<label>Nome</label>
<br>
<input type="text" name="nomeCriar" pattern="[a-zA-Z0-9]+" required minlength="3" maxlength="16" title="Nome inválido" placeholder="Seu nome"/>
</p>
<hr></hr>
<p>
<label>E-mail</label>
<br>
<input type="text" name="emailCriar" required pattern="[^@\s]+@[^@\s]+" title="E-mail inválido" placeholder="email@example.com"/>
</p>
<p>
<label>Confirme e-mail</label>
<br>
<input type="text" name="confirmeEmail" required pattern="[^@\s]+@[^@\s]+" title="E-mail inválido" placeholder="email@example.com"/>
</p>
<hr></hr>
<p>
<label>Senha</label>
<br>
<input type="password" name="senhaCriar" required minlength="6" maxlength="16" title="Senha inválida"/>
</p>
<p>
<label>Confirme senha</label>
<br>
<input type="password" name="confirmeSenha" required minlength="6" maxlength="16" title="Senha inválida"/>
</p>
<p>
<button class="formButton" type="submit" name="criarConta" value="criarConta">Criar Conta</button> Ou
<a href="index.php" >Fazer login</a>
</p>
</form>
<div class="footerSpacer"></div>
<footer>
<a>This is the footer ok :} Copyright 2023.</a>
</footer>
</body>
</html>