-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrar.php
150 lines (120 loc) · 5.51 KB
/
entrar.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<!-- Estilo CSS -->
<link rel="stylesheet" type="text/css" href="css/entrar.css">
<link rel="icon" href="img/logo.ico">
<title>Codex & Projectu</title>
</head>
<body>
<!--- inicio menu --->
<header>
<nav class="navbar navbar-expand-md">
<div class="container">
<a href="" class="navbar-brand"><img src="img/logo.png" width="70px"></a>
<button class="navbar-toggler" data-toggle="collapse" data-target="#menu"><i class="fas fa-bars text-white"></i></button>
<div class="collapse navbar-collapse" id="menu">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a href="home.php" class="nav-link">Home</a></li>
<li class="nav-item"><a href="sobre.php" class="nav-link">Sobre nós</a></li>
<li class="nav-item"><a href="projetos.php" class="nav-link">Projetos</a></li>
<?php
if (!isset($_SESSION['logado'])) {
echo '<li class="nav-item"><a href="cadastro.php" class="nav-link">Inscrever-se</a></li>';
}
?>
<li class="nav-item"><?php
if (!isset($_SESSION['logado'])) {
echo '<a href="entrar.php" class="btn btn-outline-light">Entrar</a>';
} else if ($_SESSION['logado'] == "true") {
echo "<a href='user/userinterface.php'>FOTO AQUI</a>";
}
?></li>
</ul>
</div>
</div>
</nav>
</header>
<!--- final menu --->
<!--- inicio login --->
<div class="container">
<div class="row">
<div class='col-sm-12'>
<div class="box mt-4" style='height: 18rem;width: 16rem;position: relative;'>
<?php
if (!isset($_POST['entrar']) == FALSE) {
// inclusões
include_once("back-end/configdb.php");
include_once("back-end/create_all.php");
// campos
$email = $_POST['email'];
$senha = $_POST['senha'];
// verficar se os campos estão vazios
if (!isset($email) == TRUE || !isset($email) == TRUE) {
echo "<script>alert('Todos os campos são requeridos.');</script>";
} else {
// conexão
$conn = iniciaDB("codexp49_usuarios");
// buscar por usuário
$busca = "SELECT * FROM users WHERE email = :email AND senha = :senha;";
$stmt = $conn -> prepare($busca);
// valores
$stmt -> bindValue(':email', $email);
$stmt -> bindValue(':senha', md5($senha));
$stmt -> execute();
$rows = $stmt -> rowCount();
$lista = $stmt -> fetchAll();
foreach ($lista as $value) {
$id = $value[0];
$estado = $value[8];
}
if ($rows == 0) {
echo "<script>alert('Usuário ou senha incorretos.');</script>";
} else if ($rows == 1) {
if ($estado == "Cadastrado") {
echo "<script>alert('Usuário logado com sucesso!');</script>";
$_SESSION['logado'] = 'true';
$_SESSION['id'] = $id;
echo "<script>window.location.href='home.php'</script>";
} else if ($estado == "Em análise") {
echo "<script>alert('Você ainda não confirmou o seu email!');</script>";
$_SESSION['id'] = $id;
echo "<script>window.location.href='other/confirmMail.php';</script>";
}
}
}
}
?>
<h2>Entrar</h2>
<form method="post">
<input type="email" name="email" placeholder="Digite o seu email" required>
<br>
<input type="password" name="senha" placeholder="Digite a sua senha" required>
<br>
<input type="submit" value="Entrar" name='entrar'><br><br>
<a href="#" style='color: white;'>Recuperar senha</a><br>
<a href="cadastro.php" style='color: white;'>Criar conta</a>
</form>
</div>
</div>
</div>
</div>
<!--- final login --->
<!---rodapé --->
<footer id="rodape" class='p-0' style='margin-top: 22%;'>
<img src="img/logo.png" width="70px">Todos os direitos reservados © LilCode Team 2021<br>
<ul><li style='display: inline;'><a href='other/politica.php' style='color:white;'>POLÍTICA</a></li> | <li style='display: inline;'><a href='other/termos-uso.php' style='color:white;'>TERMOS DE USO</a></li></ul>
</footer>
<!--Boostrap Scrpit links-->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.3/css/all.css" integrity="sha384-SZXxX4whJ79/gErwcOYf+zWLeJdY/qpuqC4cAa9rOGUstPomtqpuNWT9wdPEn2fk" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="bootstrap/js/bootstrap.bundle.min.js"></script>
</body>
</html>