-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
235 lines (212 loc) · 7.9 KB
/
index.php
File metadata and controls
235 lines (212 loc) · 7.9 KB
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php include_once('php/database.php');
if(!isset($_SESSION['email'])){
header("location: registration.php");
}
else {
if(isset($_SESSION['groups']) && $_SESSION['groups'] != NULL) {
$group_id = $_SESSION['groups'];
$sql = "SELECT name FROM groups WHERE id = '$group_id'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$group_name = $row["name"];
}
}
echo '<style type="text/css">
#id_group_search {
display: none;
}
#id_meal {
display: block;
}
</style>';
}
else{
echo '<style type="text/css">
#id_group_search {
display: block;
}
#id_meal {
display: none;
}
</style>';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Bachelor - Home</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Bree+Serif">
<script src="scripts/chat.js" type="text/javascript"></script>
<script src="scripts/functions.js" type="text/javascript"></script>
<style>
table {
width: 100%;
padding: 5px;
margin-top: 10px;
border-radius: 4px;
background-color: #bbb;
}
th, td{
border: 1px solid black;
border-collapse: collapse;
border-radius: 4px;
}
</style>
</head>
<body>
<!--header start-->
<header>
<div class="top_nav">
<!--header logo start-->
<div class="nav_left">
<a href="#">Bachelor</a>
</div>
<!--header logo end-->
<!--header menu start-->
<div class="nav_right">
<a href="#">Home</a>
<a href="GroupSearch.php">Search</a>
<a href="complain.php">Complain</a>
<a class="active_menu" href="php/logout.php">Logout</a>
</div>
<!--header menu end-->
</div>
</header>
<!--header end-->
<!--container start-->
<div class="container">
<!--container left start-->
<div class="left">
<div class="user">
<h3 id="main_user_name">Welcome <?php if(isset($_SESSION['name'])){echo $_SESSION['name'];} ?></h3>
<h4 id="main_user_email"><?php if(isset($_SESSION['email'])){echo $_SESSION['email'];} ?></h4>
</div>
<div id="id_group_search" class="group_search">
<form method="post">
<h3>Create Group</h3>
<input type="text" name="create_group" placeholder="Group Name" required>
<input type="submit" name="create_group_button" value="Create">
</form>
<?php
if(isset($_POST['create_group']) && isset($_SESSION['id'])) {
$GroupName = $_POST['create_group'];
$AdminID = $_SESSION['id'];
$check = mysqli_query($conn, 'select 1 from `groups`');
if($check == FALSE){
$create = "CREATE TABLE groups (
id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
admin INT(20) NOT NULL
)";
if (!mysqli_query($conn, $create)) {
echo "Error found! Please try again later";
}
}
$sql = "INSERT INTO groups (name, admin) VALUES('$GroupName', '$AdminID')";
if (mysqli_query($conn, $sql)) {
$SetGroupSql = "UPDATE users SET groups = (SELECT id FROM groups WHERE name = '$GroupName' AND
admin = '$AdminID') WHERE id = '$AdminID'";
if(mysqli_query($conn, $SetGroupSql)) {
echo "<p style='text-align:center; color:green; width: 100%; padding: 5px; margin-top: 10px; border-radius: 4px; background-color: #bbb;'>Group Created</p>";
header("location: php/logout.php");
}
}
else {
echo "<p style='text-align:center; color:red; width: 100%; padding: 5px; margin-top: 10px; border-radius: 4px;
background-color: #bbb;'>Error found!</p>";
}
}
?>
</div>
<div id="id_meal" class="meal">
<h3>Group: <?php if(isset($group_name)) echo $group_name; ?></h3>
<h4 id="main_balance">Account Balance: 0.0 tk</h4>
<p id="main_cash_in">Total Cash In: 0.0 tk</p>
<p id="main_cost">Total Cost: 0.0 tk</p>
<p id="main_meal">Total Meal: 0</p>
<p id="main_meal_rate">Meal Rate: 0.0 tk</p>
</div>
</div>
<!--container left start-->
<!--container middle start-->
<div class="main">
<div class="article">
<p style="text-align: center;">Welcome to Bachelor</p>
</div>
</div>
<!--container middle end-->
<!--container right start-->
<div class="right">
<div class="important_info">
<marquee>Welcome to Bachelor website. It's a group Database project developed by <a href="https://www.facebook.com/SalekurPolas3">Salekur Rahaman</a>, <a href="https://www.facebook.com/profile.php?id=100003164965915">Ania Chowdhury</a> and <a href="https://www.facebook.com/profile.php?id=100006116749308">Syeda Tasmiah Asad</a>.</marquee>
</div>
<div class="notice">
<h3 style="text-align: center;">Notice</h3>
<p>There is no notice at this moment please try again later or refresh your browser, thank you.</p>
</div>
<div class="member_search">
<form action="" method="post">
<h3>Add Member</h3>
<input type="text" name="search_member" placeholder="Search Member" required>
<input type="submit" name="search_member_button" value="Search">
</form>
<!--displaying search value start-->
<?php
if (isset($_POST['search_member'])) {
$MemberSearchValue = $_POST['search_member'];
$MemberSearchSql = "SELECT id, name, groups FROM users WHERE name LIKE '%".$MemberSearchValue."%'";
$MemberSearchResult = $conn->query($MemberSearchSql);
if ($MemberSearchResult->num_rows > 0) {
$counter = 0;
?>
<table>
<tr>
<th>No.</th>
<th>Name</th>
<th>Action</th>
</tr>
<?php
while ($MemberRow = $MemberSearchResult -> fetch_assoc()) {
if($MemberRow["groups"] == NULL || empty($MemberRow["groups"])) {
$member_id = $MemberRow["id"];
$counter = $counter + 1;
?>
<!--adding new row start-->
<tr>
<th><?php echo "<p>".$counter.".</p>"; ?></th>
<th><?php echo $MemberRow["name"]; ?></th>
<th><p style="cursor: pointer; color: green" onclick="AddMember(<?php echo $member_id; ?>, <?php echo $group_id; ?>)">ADD</p></th>
</tr>
<!--adding new row end-->
<?php
}
}
if($counter == 0) {
echo "<p style='text-align:center; color:red; width: 100%; padding: 5px; margin-top: 10px; border-radius: 4px; background-color: #bbb;'>No Member Found!</p>";
}
?>
</table>
<?php
}
else {
echo "<p style='text-align:center; color:red; width: 100%; padding: 5px; margin-top: 10px; border-radius: 4px; background-color: #bbb;'>No Member Found!</p>";
}
}
?>
<!--displaying search value end-->
</div>
</div>
<!--container right end-->
</div>
<!--container end-->
<!--page footer start-->
<footer>
<p>Copyright all right reserved by <a href="#">Bachelor</a></p>
</footer>
<!--page footer end-->
</body>
</html>