Cadastro Unshatter
<?php
/**
* Template Name: Cadastro Unshatter
*/
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try{
$nome = $_POST['nome'];
$email = $_POST['email'];
$senha = $_POST['senha'];
$telefone = $_POST['telefone'];
$pdo = new PDO(
"pgsql:host=localhost;dbname=Unshatter",
"postgres",
"2096",
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
]
);
$senhaHash = password_hash($senha, PASSWORD_DEFAULT);
$sql = "INSERT INTO usuarios (nome, email, senha, telefone)
VALUES (:nome, :email, :senha, :telefone)";
$stmt = $pdo->prepare($sql);
$stmt->execute([
':nome' => $nome,
':email' => $email,
':senha' => $senhaHash,
':telefone' => $telefone
]);
} catch (PDOException $e){
echo "Erro no banco de dados " . $e->getMessage();
}
}
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Unshatter Brasil</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1 id="titulo">Linkin Park - Unshatter</h1>
<h2 id="subtitulo">Encontre fãs de Linkin Park perto de você para viver a experiência do filme Unshatter em conjunto!</h2>
<br>
<div id="formulario">
<form action="cadastro.php" method="post">
<div id="campo">
<label for="nome" id="nometexto">Nome</label>
<input type="text" name="nome" id="nome" placeholder="Digite seu nome" required>
</div>
<br>
<br>
<div id="campo">
<label for="email" id="emailtexto">E-mail</label>
<input type="email" name="email" id="email" placeholder="Digite seu melhor e-mail" required>
</div>
<br>
<br>
<div id="campo">
<label for="senha" id="senhatexto">Senha</label>
<input type="password" name="senha" id="senha" placeholder="Crie uma senha" required>
</div>
<br>
<br>
<div id="campo">
<label for="telefone" id="telefonetexto">Telefone</label>
<input type="tel" name="telefone" id="telefone" placeholder="Digite seu telefone com DDD" minlength="10" maxlength="10" pattern="[0-9]{10}" required>
</div>
<br>
<br>
<div id="botao">
<button type="submit">Cadastrar</button>
</div>
</form>
</div>
<img src="lp-foto.png" alt="lp-foto">
</body>
</html>
