Viewing file: user.php (4.91 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
error_reporting(0);
include 'conn.php';
require_once "auth.php";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><?php include('title.php') ?></title>
<link rel="shortcut icon" type="image/png" href="images/fav.png">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/themify-icons.css">
<link rel="stylesheet" href="css/animate.css">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/red.css" id="style_theme">
<link rel="stylesheet" href="css/responsive.css">
<link rel="stylesheet" href="charts/css/morris.css">
<link rel="stylesheet" href="css/jquery-jvectormap.css">
<link rel="stylesheet" href="datatable/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="plugins/summernote/summernote-bs4.css">
<script src="js/modernizr.min.js"></script>
<link rel="stylesheet" href="dist/css/user_css.css">
</head>
<body>
<!-- Pre Loader -->
<div class="loading">
<div class="spinner">
<div class="double-bounce1"></div>
<div class="double-bounce2"></div>
</div>
</div>
<!--/Pre Loader -->
<div class="wrapper">
<!-- Sidebar -->
<?php include('sidebar.php') ?>
<!-- /Sidebar -->
<!-- Page Content -->
<div id="content">
<div>
<?php include('topbar.php') ?>
</div>
<?php
$userr= mysqli_query($con,"SELECT * FROM users");
if(isset($_POST['delete_user'])) {
$user_id = $_POST['user_id'];
$query = "DELETE FROM users WHERE user_id='$user_id'";
mysqli_query($con, $query);
echo "<script>alert('User Deleted Successfully');</script>
<script>window.location.href = 'user.php'</script>";
session_start();
unset($_SESSION["user_id"]);
}
if(isset($_POST['block_user'])) {
$user_id = $_POST['user_id'];
$query = "UPDATE users SET is_deleted= 1 WHERE user_id='$user_id'";
mysqli_query($con, $query);
echo "<script>alert('User Blocked Successfully');</script>
<script>window.location.href = 'user.php'</script>";
session_start();
unset($_SESSION["user_id"]);
}
if(isset($_POST['edit_user'])) {
$user_id = $_POST['user_id'];
$new_username = $_POST['new_username'];
$query = "UPDATE users SET name='$new_username' WHERE user_id='$user_id'";
mysqli_query($con, $query);
echo "<script>alert('User Name Updated Successfully');</script>
<script>window.location.href = 'user.php'</script>";
}
?>
<div class="row no-margin-padding">
<div class="col-md-6">
<h3 class="block-title">Manage Users</h3>
</div>
<div class="col-md-6">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="index.html">
<span class="ti-home"></span>
</a>
</li>
<li class="breadcrumb-item">User</li>
</ol>
</div>
</div>
<table class="table table-bordered table-striped">
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
</tr>
<?php
while($user=mysqli_fetch_array($userr)){
?>
<tr>
<td><?php echo $user['user_id'] ?></td>
<td><?php echo $user['name'] ?></td>
<td><?php echo $user['email'] ?></td>
<td>
<form method="post">
<input type="hidden" name="user_id" value="<?php echo $user['user_id']; ?>">
<textarea name="new_username"><?php echo $user['name']; ?></textarea>
<button class="edit-user-btn" type="submit" name="edit_user">Save Changes</button>
</form>
<!-- Form for deleting a comment -->
<form method="post">
<input type="hidden" name="user_id" value="<?php echo $user['user_id']; ?>">
<button class="delete-user-btn" type="submit" name="delete_user">Delete user</button>
<button class="delete-user-btn" type="submit" name="block_user">Block user</button>
</form>
</td>
</tr>
<?php } ?>
</table>
<!-- /Main Content -->
</div>
<!-- /Page Content -->
</div>
<!-- Back to Top -->
<a id="back-to-top" href="#" class="back-to-top">
<span class="ti-angle-up"></span>
</a>
<script src="plugins/jquery/jquery.min.js"></script>
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="dist/js/adminlte.min.js"></script>
<script src="dist/js/demo.js"></script>
<script src="plugins/summernote/summernote-bs4.min.js"></script>
<script>
$(function () {
$('.textarea').summernote()
})
</script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="datatable/jquery.dataTables.min.js"></script>
<script src="datatable/dataTables.bootstrap4.min.js"></script>
<script src="js/custom.js"></script>
</body>
</html>
|