-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate_table.php
More file actions
45 lines (37 loc) · 1.17 KB
/
create_table.php
File metadata and controls
45 lines (37 loc) · 1.17 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
<html>
<body>
<p> Criando Tabela </p>
<?php
echo "<p>Criando tabela no banco de dados... </p>";
try {
$conn = new PDO("mysql:host=localhost;dbname=bancophp", "root", "");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "CREATE TABLE dados (
Nome_completo varchar(200) NOT NULL,
Data_de_nascimento date NOT NULL,
CPF varchar(80) NOT NULL,
Telefone varchar(80) NOT NULL,
Email varchar(200) NOT NULL,
username varchar(200) NOT NULL,
PRIMARY KEY(username),
senha varchar(200) NOT NULL
)";
$sql2 = "CREATE TABLE pontuacao (
pontos int NOT NULL,
level int NOT NULL,
tempo int NOT NULL,
username_dados varchar(200) NOT NULL,
foreign key (username_dados) references dados(username)
)";
$conn->exec($sql);
$conn->exec($sql2);
echo "<p>Tabela criada com sucesso</p>";
$conn = null;
}
catch(PDOException $e)
{
echo "Ocorreu um erro: " . $e->getMessage();
}
?>
</body>
</html>