-
Notifications
You must be signed in to change notification settings - Fork 0
/
cadastro-usuario.php
50 lines (39 loc) · 1.33 KB
/
cadastro-usuario.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
<html>
<head>
<title>Cadastro</title>
<meta charset="utf-8">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
</head>
<body>
<div>
<div>
<?php
define( 'MYSQL_HOST', 'localhost' );
define( 'MYSQL_USER', 'root' );
define( 'MYSQL_PASSWORD', '' );
define( 'MYSQL_DB_NAME', 'cadastro' );
$nome = $_GET["nome"];
$cpf = $_GET["cpf"];
$email = $_GET["email"];
$PDO = new PDO( 'mysql:host=' . MYSQL_HOST . ';dbname=' . MYSQL_DB_NAME, MYSQL_USER, MYSQL_PASSWORD );
$sql = "insert into usuarios (nome, cpf, email) values ('{$nome}', '{$cpf}', '{$email}')";
$stmt = $PDO->prepare( $sql );
$result = $stmt->execute();
if($result) {
?>
<p class="alert-success">
Nome: <?= $nome; ?>, CPF: <?= $cpf; ?>, E-mail: <?= $email; ?> - Cadastro realizado com sucesso!
</p>
<?php
} else {
?>
<p class="alert-danger">
ERRO - O produto não foi adicionado!
</p>
<?php
}
?>
</div>
</div>
</body>
</html>