ok
Direktori : /home/pequenacapitolio/www/administrador/ |
Current File : /home/pequenacapitolio/www/administrador/usuarios_admin.php |
<?php include '../conexao.php'; // ############# INSERE USUÁRIO ################### if (isset($_GET["act"]) && $_GET["act"] == "inserir") { $user_nome = $_POST["nome"]; $user_login = $_POST["login"]; $user_senha = $_POST["senha"]; $dados_cat = array( 'nome' => $user_nome, 'logar' => $user_login, 'senha' => MD5($user_senha) ); $conn->prepare("INSERT INTO usuarios (nome, `login`, senha) VALUES (:nome, :logar, :senha)")->execute($dados_cat); $redirect = "/administrador/usuarios_admin.php"; //$redirect = "/administrador/usuarios_admin.php"; header("location:$redirect"); } // ############# DELETA USUÁRIO ################### if (isset($_GET["act"]) && $_GET["act"] == "excluir") { $user_exclui = $_GET["id"]; $dados_cat = array( 'id' => $user_exclui, ); $conn->prepare("DELETE FROM usuarios WHERE idusuarios = :id")->execute($dados_cat); $redirect = "/administrador/usuarios_admin.php"; //$redirect = "/administrador/usuarios_admin.php"; header("location:$redirect"); } // ############# UPDATE CATEGORIA ################### if (isset($_GET["act"]) && $_GET["act"] == "editar") { $user_id = $_GET["id"]; $user_nome = $_POST["nome"]; $user_login = $_POST["login"]; $user_senha = $_POST["senha"]; $dados_atualiza = array( 'id' => $user_id, 'nome' => $user_nome, 'logar' => $user_login, 'senha' => MD5($user_senha) ); $conn->prepare("UPDATE usuarios SET nome = :nome, `login` = :logar, senha = :senha WHERE idusuarios = :id")->execute($dados_atualiza); $redirect = "/administrador/usuarios_admin.php"; //$redirect = "/administrador/usuarios_admin.php"; header("location:$redirect"); } ?> <!DOCTYPE html> <html> <head> <?php include 'include_head.php';?> </head> <body class="hold-transition skin-blue sidebar-mini"> <!-- Site wrapper --> <div class="wrapper"> <?php include 'estrutura_menu.php';?> <!-- =============================================== --> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <!-- Content Header (Page header) --> <section class="content-header"> <h1> Usuários Admin <!-- <small>it all starts here</small> --> </h1> <!-- <ol class="breadcrumb"> <li><a href="#"><i class="fa fa-dashboard"></i> Início</a></li> <li><a href="#">Paginas</a></li> <li><a href="#">Gerenciar Categorias</a></li> </ol> --> </section> <!-- Main content --> <section class="content"> <?php $user = $conn->query("SELECT * FROM usuarios order by idusuarios desc"); ?> <div class="row"> <div class="col-xs-12"> <div class="box"> <div class="box-body table-responsive no-padding"> <a href="#" data-toggle="modal" data-target="#modal-inserir" class="btn btn-primary btn-flat" style="float:right; margin:20px;">Inserir Usuário</a> </div> <?php if ($user->rowCount()) {?> <!-- /.box-header --> <div class="box-body table-responsive no-padding"> <table class="table table-hover"> <tr> <th width="80%">Nome:</th> <th width="20%">Ações:</th> </tr> <?php while ($usuario = $user->fetch(PDO::FETCH_OBJ)) {?> <tr> <td width="80%"><?php echo $usuario->nome ?></td> <td width="20%"> <a href="#" data-toggle="modal" data-target="#modal-atualizar<?php echo $usuario->idusuarios ?>"><i style="margin-right:20px;" class="fas fa-pencil-alt"></i></a> <a href="usuarios_admin.php?act=excluir&id=<?php echo $usuario->idusuarios ?>"><i class="fas fa-trash-alt"></i></a> </td> </tr> <?php }?> </table> </div> <?php }?> <!-- /.box-body --> </div> <!-- /.box --> </div> </div> </section> <!-- /.content --> </div> <!-- /.content-wrapper --> <?php include 'estrutura_rodape.php';?> <!-- ########## MODAL INSERIR ########## --> <div class="modal fade" id="modal-inserir"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span></button> <h4 class="modal-title">Inserir Categoria</h4> </div> <div class="modal-body"> <div class="row"> <form action="usuarios_admin.php?act=inserir" method="POST"> <div class="col-xs-12 pad"> <input type="text" name="nome" class="form-control" placeholder="Nome" required> </div> <div class="col-xs-12 pad"> <input type="text" name="login" class="form-control" placeholder="Login" required> </div> <div class="col-xs-12 pad"> <input type="password" name="senha" class="form-control" placeholder="Senha" required> </div> <div class="col-xs-12"> <button type="submit" class="btn btn-primary" style="margin-top:20px;">Cadastrar</button> </div> </form> </div> </div> <!-- <div class="modal-footer"> <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Fechar</button> </div> --> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div> <!-- /.modal --> <?php $userparamodal = $conn->query("SELECT * FROM usuarios order by idusuarios desc"); // ##### SELECT IGUAL O DA LISTA COM MESMA ORDENAÇÃO PARA QUE TENHA O MESMO RESULTADO ####### while ($usermodal = $userparamodal->fetch(PDO::FETCH_OBJ)) { // ######### LAÇO DE REPETIÇÃO MODAL CONFORME SELECT ANTERIOR ?> <!-- ########## MODAL ATUALIZAR ########## --> <div class="modal fade" id="modal-atualizar<?php echo $usermodal->idusuarios ?>"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span></button> <h4 class="modal-title">Atualizar Usuário</h4> </div> <div class="modal-body"> <div class="row"> <form action="usuarios_admin.php?act=editar&id=<?php echo $usermodal->idusuarios ?>" method="POST"> <div class="col-xs-12"> <input type="text" name="nome" class="form-control" placeholder="Nome" value="<?php echo $usermodal->nome ?>"> </div> <div class="col-xs-12"> <input type="text" name="login" class="form-control" placeholder="Login" value="<?php echo $usermodal->login ?>"> </div> <div class="col-xs-12"> <input type="password" name="senha" class="form-control" placeholder="Senha" value="<?php echo $usermodal->senha ?>"> </div> <div class="col-xs-12"> <button type="submit" class="btn btn-primary" style="margin-top:20px;">Atualizar</button> </div> </form> </div> </div> <!-- <div class="modal-footer"> <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Fechar</button> </div> --> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div> <!-- /.modal --> <?php }?> <!-- Add the sidebar's background. This div must be placed immediately after the control sidebar --> <div class="control-sidebar-bg"></div> </div> <!-- ./wrapper --> <!-- jQuery 3 --> <script src="bower_components/jquery/dist/jquery.min.js"></script> <!-- Bootstrap 3.3.7 --> <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> <!-- SlimScroll --> <script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script> <!-- FastClick --> <script src="bower_components/fastclick/lib/fastclick.js"></script> <!-- AdminLTE App --> <script src="dist/js/adminlte.min.js"></script> <!-- AdminLTE for demo purposes --> <script src="dist/js/demo.js"></script> <script> $(document).ready(function () { $('.sidebar-menu').tree() }) </script> </body> </html>