This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
atualizarSenha.php
104 lines (97 loc) · 5.14 KB
/
atualizarSenha.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
<?php
require_once './conexao.php';
session_start();
function validaAcesso(){
$x = 0;
if(isset($_SESSION['clienteLogado'])){
$x = 1;
} elseif(isset($_SESSION['analistaLogado'])){
$x = 1;
}
if($x == 0):
header('Location: ./acessoNegado.php');
endif;
}
validaAcesso();
$msgErro = false;
$msgSucesso = false;
if(!empty($_POST['novaSenha']) && !empty($_POST['senhaAtual'])) {
$statement = $db->prepare("SELECT senha FROM pessoa WHERE cpf = :cpf");
$statement->execute(array(
":cpf" => $_SESSION['cpf'],
));
$pessoa = $statement->fetch(PDO::FETCH_ASSOC);
//echo $pessoa['senha'];
// echo '<br>';
//echo md5($_POST['senhaAtual']);
if ($pessoa['senha'] == md5($_POST['senhaAtual'])) {
$statement2 = $db->prepare("UPDATE pessoa SET senha = :senha WHERE cpf = :cpf");
$statement2->execute(array(
':senha' => md5($_POST['novaSenha']),
':cpf' => $_SESSION['cpf']
));
$msgSucesso = true;
}
else {
$msgErro = true;
}
}
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title>InvistAí</title>
<meta charset="UTF-8">
<link rel="shortcut icon" href="https://img.icons8.com/fluent/96/000000/bad-idea.png">
<link rel="stylesheet" href="./estilo.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="./script.js"></script>
<script type="text/javascript" src="./pace.min.js"></script>
</head>
<body>
<div class="container-fluid">
<!-- Menu de Navegação -->
<div class="row">
<div class="col-sm-12" id="navbar">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="#"><img src="https://img.icons8.com/fluent/24/000000/bad-idea.png"/> InvistAí</font></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link disabled">Home</a></li>
<li class="nav-item"><a class="nav-link disabled">Perfil</a></li>
<li class="nav-item"><a class="nav-link disabled">Ações</a></li>
<li class="nav-item"><a class="nav-link disabled">Clientes</a></li>
<li class="nav-item"><a class="nav-link" href="#" onclick="confirmlogout('logout.php')" id="logout"><?=$_SESSION['nome']?>-logout</a></li>
</ul>
</div>
</div>
</nav>
</div>
</div>
<div class="row">
<div class="col-sm-12 text-center">
<?= $msgSucesso ? "<div class='alert alert-success alert-dismissible fade show' role='alert'>Senha atualizada!<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>" : "" ?>
<?= $msgErro ? "<div class='alert alert-error alert-dismissible fade show' role='alert'>Dados incorretos!<button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>" : "" ?>
<h1>Atualizar Senha</h1>
<form action="atualizarSenha.php" method="post">
<div class="form-floating mb-3">
<input type="password" class="form-control" placeholder="Senha Atual" maxlength="5" required name="senhaAtual">
<label for="floatingInput">Senha atual</label>
</div>
<div class="form-floating mb-3">
<input type="password" class="form-control" placeholder="Nova Senha" maxlength="5" required name="novaSenha">
<label for="floatingInput">Nova senha</label>
</div>
<button type="button" class="btn btn-danger" onclick="window.location.href='logout.php'">Sair</button>
<button type="submit" class="btn btn-success" id="submitWithEnter" onclick="return validadePassoword()">Atualizar</button>
<button type="reset" class="btn btn-warning">Limpar</button>
</form>
</div>
</div>
</div>
</body>
</html>