-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.php
62 lines (49 loc) · 1.85 KB
/
main.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
<html>
<body>
<h2>Bloco de Notas</h2>
<h3>Menu</h3>
<?php
session_start();
include('functions.php');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$email = test_input($_POST["email"]);
$pass = test_input($_POST["password"]);
}
else{
$email = $_SESSION['email'];
$pass = $_SESSION['pass'];
}
$connection=createConnection();
$sql = "SELECT * from utilizador where email='$email'";
$result = $connection->query($sql);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
$rows = $result->fetchAll();
$rowCount = count($rows);
if ($rowCount != 1) {
die('Email inválido');
}
$database_pass = $rows[0]['password'];
if ($database_pass != $pass){
die('Password inválida');
}
$_SESSION['id'] = $rows[0]['userid'];
$_SESSION['nome'] = $rows[0]['nome'];
$_SESSION['email'] = $rows[0]['email'];
$_SESSION['pass'] = $rows[0]['password'];
echo("<h5>Olá {$_SESSION['nome']} !</h5>");
echo("<p><a href=\"inserir_pagina_form.php?\">Inserir uma nova pagina</a></p>");
echo("<p><a href=\"inserir_tipo_registo_form.php?\">Inserir um novo tipo de registo</a></p>");
echo("<p><a href=\"inserir_campo_form.php?\">Inserir novos campos para um tipo de registo</a></p>");
echo("<p><a href=\"retirar_pagina_form.php?\">Retirar uma página</a></p>");
echo("<p><a href=\"retirar_tipo_registo_form.php?\">Retirar um tipo de registo</a></p>");
echo("<p><a href=\"retirar_campo_form.php?\">Retirar um campo de um tipo de registo</a></p>");
echo("<p><a href=\"inserir_registo_form.php?\">Inserir um registo</a></p>");
echo("<p><a href=\"ver_pagina_form.php?\">Ver uma página</a></p>");
echo("<br></br>");
echo("<h7><a href=\"logout.php?\">Logout</a></h7>");
$connection->close();
?>
</body>
</html>