-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCadProfPHP.php
More file actions
57 lines (42 loc) · 1.72 KB
/
Copy pathCadProfPHP.php
File metadata and controls
57 lines (42 loc) · 1.72 KB
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
<?php
include('conexao.php');
if (isset($_POST['email']) && isset($_POST['senha'])) {
$email = $_POST['email'];
$email = mysqli_real_escape_string($conexao, $email);
$senha = $_POST['senha'];
$senha = mysqli_real_escape_string($conexao, $senha);
$sql_check_email = "SELECT email FROM register.emailsenha WHERE email = ?";
$stmt_check_email = mysqli_prepare($conexao, $sql_check_email);
if ($stmt_check_email) {
mysqli_stmt_bind_param($stmt_check_email, "s", $email);
mysqli_stmt_execute($stmt_check_email);
mysqli_stmt_store_result($stmt_check_email);
if (mysqli_stmt_num_rows($stmt_check_email) > 0) {
echo "E-MAIL JÁ CADASTRADO!";
mysqli_stmt_close($stmt_check_email);
mysqli_close($conexao);
exit();
}
mysqli_stmt_close($stmt_check_email);
} else {
die("Erro na verificação de e-mail: " . mysqli_error($conexao));
}
$sql_insert_user = "INSERT INTO register.emailsenha (email, senha) VALUES (?, ?)";
$stmt_insert_user = mysqli_prepare($conexao, $sql_insert_user);
if ($stmt_insert_user) {
mysqli_stmt_bind_param($stmt_insert_user, "ss", $email, $senha);
mysqli_stmt_execute($stmt_insert_user);
if (mysqli_stmt_affected_rows($stmt_insert_user) > 0) {
header("Location: index.php");
} else {
echo "Erro ao cadastrar usuário: " . mysqli_error($conexao);
}
mysqli_stmt_close($stmt_insert_user);
} else {
die("Erro na preparação da consulta: " . mysqli_error($conexao));
}
mysqli_close($conexao);
} else {
echo "Dados incompletos. Por favor, forneça um e-mail e uma senha.";
}
?>