-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathusers.php
172 lines (159 loc) · 5.36 KB
/
users.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
/****************************
* File Name: users.php *
* Author: Ammar S.A.A *
* Output: List of users *
****************************/
require('config.php');
require(WEBSITE_PATH.'./includes/db_connection.php');
require(WEBSITE_PATH.'./includes/session.php');
include(WEBSITE_PATH.'./includes/header.php');
include(WEBSITE_PATH.'./includes/logo.php');
include(WEBSITE_PATH.'./includes/menu.php');
if(isset($_GET['action']) && isset($_GET['id']))
{
$id = $_GET['id'];
$sql = "DELETE FROM tblusers WHERE id={$id}";
$result = $conn->query($sql);
if($result)
{
$msg = "<div class='alert alert-success'>Record Deleted Successfully.</div>";
}
else{
$msg = "<div class='alert alert-danger'>Record Not Deleted Successfully.</div>";
}
}
$sql = "SELECT * FROM tblusers
ORDER BY id DESC";
if(isset($_POST['search']) && !empty($_POST['search'])){
$search = trim($_POST['search']);
$sql="SELECT * FROM tblusers
WHERE full_name LIKE '%{$search}%'
OR email_id LIKE '%{$search}%'
OR mobile_no LIKE '%{$search}%'
OR status LIKE '%{$search}%'
";
}
$result = $conn->query($sql);
if (isset($msg))
{
echo $msg;
}
?>
<?php
if (!IfIsUser($conn) && $_SESSION['user_name']) {
?>
<section id="content">
<div class="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col md-8 lg-10 sm-6">
<!--Search Nav Start-->
<nav class="navbar navbar-light default-color bg-transparent nav justify-content-between">
<a class="navbar-brand">Users' List</a>
<!--Search Form Start-->
<form class="form-inline form-responsive my-0 form-inline bg-transparent" method="POST">
<div class="md-form form-sm my-0">
<input type="text" class="form-control" name="search" placeholder="Search..." />
<button class="btn btn-sm my-0 btn-transparent" type="submit">
<i class="material-icons">search</i>
</button>
</div>
</form>
<!--Search Form End-->
<div class="btn-group">
<a class="btn btn-outline-primary" href="user-signup.php" role="button">Add User</a>
<a class="btn btn-outline-primary" href="admin-signup.php" role="button">Add Admin</a>
</div>
</nav>
<!--Search Nav End-->
</div>
</div>
<div class="row">
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead class="thead thead-light">
<tr>
<th class="text-nowrap">ID</th>
<th class="text-nowrap">Full Name</th>
<th class="text-nowrap">E-Mail</th>
<th class="text-nowrap">Mobile No.</th>
<th class="text-nowrap">Password</th>
<th class="text-nowrap">Status</th>
<th class="text-nowrap">Profile Picture</th>
<th class="text-nowrap">Reg. Date</th>
<th class="text-nowrap">Updt. Date</th>
<th colspan="2">Action</th>
</tr>
</thead>
<tbody>
<?php
foreach ($result as $row) {
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['full_name']; ?></td>
<td><?php echo $row['email_id']; ?></td>
<td><?php echo $row['mobile_no']; ?></td>
<td><?php echo $row['password']; ?></td>
<td><?php echo $row['status']; ?></td>
<td class="img">
<?php
if(empty($row['profile_picture']))
{
echo "<p class='initialism text-center'>No Profile<br/>Picture</p>";
}
else{
echo "<img width='55in' class='img-responsive img-circle' src='".WEBSITE_URL."./images/profile_pictures/".$row['profile_picture']."'/>";
}
?>
</td>
<td><?php echo $row['reg_date']; ?></td>
<td><?php echo $row['updation_date']; ?></td>
<td>
<button class="btn btn-warning btn-sm"><a href="<?php echo WEBSITE_URL. 'user-signup.php?id='.$row['id']; ?> "><i class="display-5 glyphicon glyphicon-edit"></i></a></button>
</td>
<td>
<button class="btn btn-danger btn-sm" onclick="delete_confirm(<?php echo $row["id"]; ?>)"><a><i class="display-5 glyphicon glyphicon-trash"></i></a></button>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<div>
<p>
<?php
if (isset($search)) {
GetTotalSearchResult($conn,$result,$search);
}else{
$total_users = GetTotal($conn, TBLUSERS);
echo "Showing total <b>".$total_users."</b> of <b>".$total_users."</b> ";
if ($total_users > 1) {
echo "results";
}else{ echo "result";}
}
?>
</p>
</div>
</div>
</div>
<br />
</div>
</div>
</section>
<?php
}else{ echo "<div class='alert alert-danger'>Access Denied!</div>"; }
?>
</div>
</div>
<script>
function delete_confirm(id) {
var txt;
if (confirm("Are you sure? you want to delete this record.")) {
window.location.href = "<?php echo WEBSITE_URL. 'users.php?action=delete&id=' ?>"+id;
}
}
</script>
<?php
include(WEBSITE_PATH.'./includes/footer.php');
?>