-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
136 lines (130 loc) · 4.21 KB
/
index.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
session_start();
include('config/db.php');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
// Consulta segura usando prepared statements
$stmt = $conn->prepare("SELECT * FROM usuarios WHERE username = ?");
$stmt->bind_param('s', $username);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows == 1) {
$user = $result->fetch_assoc();
// Verificar a senha
if (password_verify($password, $user['password'])) {
$_SESSION['username'] = $username;
header('Location: dashboard.php');
exit();
} else {
$error = "Nome de usuário ou senha incorretos!";
}
} else {
$error = "Nome de usuário ou senha incorretos!";
}
$stmt->close();
}
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login | SCE</title>
<link rel="apple-touch-icon" sizes="180x180" href="img/favicon_io/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="img/favicon_io/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="img/favicon_io/favicon-16x16.png">
<link rel="manifest" href="img/favicon_io/site.webmanifest">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-image: url('img/login.png');
background-size: cover;
background-repeat: no-repeat;
background-position: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
font-family: Arial, sans-serif;
background-color: #f4f4f4; /* Cor de fundo se a imagem não carregar */
}
.login-container {
background-color: rgba(000, 000, 000, 0.8); /* Fundo branco com 80% de opacidade */
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.9);
max-width: 400px;
width: 100%;
color: #fff;
}
h2 {
margin-bottom: 20px;
}
label {
display: block;
margin: 10px 0 5px;
text-align: left;
}
input[type="text"],
input[type="password"] {
width: calc(100% - 22px);
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 4px;
}
input[type="submit"] {
background-color: #0C6C81;
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
input[type="submit"]:hover {
background-color: #095161;
}
.error {
color: red;
margin-top: 20px;
}
.footer {
width: 100%;
background-color: #2C3739;
color: #fff;
text-align: center;
padding: 1px 0;
position: fixed;
bottom: 0;
left: 0;
font-size: 0.9em;
}
</style>
</head>
<body>
<div class="login-container">
<h2>Login</h2>
<form method="POST">
<label for="username">Nome de Usuário:</label>
<input type="text" id="username" name="username" required>
<label for="password">Senha:</label>
<input type="password" id="password" name="password" required>
<input type="submit" value="Login">
</form>
<?php if (isset($error)) echo "<p class='error'>$error</p>"; ?>
</div>
<div class="footer">
Developed by Eugenio Oliveira
</div>
</body>
</html>