-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessa_registro.php
More file actions
29 lines (24 loc) · 929 Bytes
/
processa_registro.php
File metadata and controls
29 lines (24 loc) · 929 Bytes
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
<?php
try {
$conexao = new PDO("mysql:host=127.0.0.1;dbname=banco_bueiro", 'root', '');
$conexao->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if (isset($_POST['nome']) && isset($_POST['email']) && isset($_POST['senha'])) {
$nome = $_POST['nome'];
$email = $_POST['email'];
$senha = password_hash($_POST['senha'], PASSWORD_DEFAULT);
$stmt = $conexao->prepare("INSERT INTO tb_usuarios (usuario, senha) VALUES (:usuario, :senha)");
$stmt->bindParam(':usuario', $email);
$stmt->bindParam(':senha', $senha);
if ($stmt->execute()) {
echo "Usuário registrado com sucesso!";
} else {
echo "Erro ao registrar usuário.";
}
} else {
echo "Por favor, preencha todos os campos.";
}
} catch(PDOException $e) {
echo "Erro: " . $e->getMessage();
}
$conexao = null;
?>