-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcadastro.php
72 lines (57 loc) · 1.95 KB
/
cadastro.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
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8" />
<title> Trabalho 3 - PHP </title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<header>
<div id="logo">
<img id="tetris-logo" src="img/project-logo.png" alt="logotipo">
<h1> Cadastro do Jogador </h1>
</div>
</header>
<div class = "Cadastro">
<?php
$form = "
<form action = 'cadastro.php' method='POST'>
<p> Nome Completo: <input type = 'text' name = 'nome' required = 'required' /> </p>
<p> Data de Nascimento: <input type = 'text' name = 'datanasc' required = 'required' /> </p>
<p> CPF: <input type = 'text' name = 'cpf' required = 'required'/> </p>
<p> Telefone: <input type = 'text' name = 'tel' required = 'required' /> </p>
<p> E-mail: <input type ='text' name = 'e-mail' required = 'required' /> </p>
<p> Username Novo: <input type ='text' name = 'username' required = 'required' /> </p>
<p> Senha Nova: <input type ='password' name = 'senha' required = 'required' /> </p>
<input type='submit' value='Cadastrar' name='submit'/>
</form>";
if(isset($_POST["nome"])){
try{
$conn = new PDO("mysql:host=localhost;dbname=bancophp", "root", "");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO dados VALUES (
'" . $_POST['nome'] . "',
" . $_POST['datanasc'] . ",
'" .$_POST['cpf'] . "',
'" .$_POST['tel'] . "',
'" . $_POST['e-mail'] . "',
'" . $_POST['username'] . "',
'" . $_POST['senha'] . "')";
$conn->exec($sql);
echo $form;
header("Location: cadastro.php");
}
catch(PDOException $e){
echo "Ocorreu um erro: " . $e->getMessage();
}
}
else{
echo $form;
}
?>
<form action="login.php">
<input type="submit" value="Voltar para o Login" />
</form>
</div>
</body>
</html>