-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98d0fb9
commit 744de1b
Showing
8 changed files
with
649 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Seleciona elementos do DOM | ||
const removeAdmBtn = document.getElementById('removeAdmBtn'); | ||
const confirmModal = document.getElementById('confirmModal'); | ||
const confirmBtn = document.getElementById('confirmBtn'); | ||
const cancelBtn = document.getElementById('cancelBtn'); | ||
|
||
// Abre o modal ao clicar no botão | ||
removeAdmBtn.onclick = function() { | ||
confirmModal.style.display = 'block'; | ||
} | ||
|
||
// Fecha o modal ao clicar em cancelar | ||
cancelBtn.onclick = function() { | ||
confirmModal.style.display = 'none'; | ||
} | ||
|
||
// Ação de confirmação | ||
confirmBtn.onclick = function() { | ||
window.location.href = 'src/php/removeAdm.php'; // Redireciona para a ação de remoção | ||
} | ||
|
||
// Fecha o modal se o usuário clicar fora dele | ||
window.onclick = function(event) { | ||
if (event.target == confirmModal) { | ||
confirmModal.style.display = 'none'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
session_start(); | ||
include_once('conexao.php'); // Inclui a conexão com o banco de dados | ||
|
||
// Verifica se o usuário está logado, caso contrário, redireciona para a página de login | ||
if (!isset($_SESSION['email']) || !isset($_SESSION['senha'])) { | ||
header('Location: login.html'); | ||
exit; | ||
} | ||
|
||
$logado = $_SESSION['email']; | ||
$senha = $_SESSION['senha']; | ||
|
||
// Atualiza o campo is_admin no banco de dados para 0 (remove o status de administrador) | ||
$stmt = $conn->prepare("UPDATE usuario SET is_admin = 0 WHERE email = ? AND senha = ?"); | ||
$stmt->bind_param("ss", $logado, $senha); | ||
|
||
if ($stmt->execute()) { | ||
// Atualiza a sessão para refletir a mudança | ||
$_SESSION['is_admin'] = 0; | ||
|
||
// Redireciona para a página de perfil após a atualização | ||
header("Location: ../../perfil.php"); | ||
exit; | ||
} else { | ||
// Se ocorrer um erro, exibe um alerta e redireciona de volta para o perfil | ||
echo "<script>alert('Erro ao remover status de administrador');</script>"; | ||
echo "<script>window.location.href = '../../perfil.php';</script>"; | ||
} | ||
|
||
?> |
Oops, something went wrong.