-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgroups.php
More file actions
107 lines (93 loc) · 3.38 KB
/
groups.php
File metadata and controls
107 lines (93 loc) · 3.38 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
<?php
session_start();
require 'php/db_init.php';
require 'partials/header.php';
$notification="";
if(isset($_POST['group_create'])){
$group_name = $_POST['group_name'];
$group_desc = $_POST['group_desc'];
$group_name_name = strtolower($group_name) . rand(1,1000);
$query="INSERT INTO groups (group_id, name, num_posts, member_array, description, group_name) VALUES (NULL, '$group_name', 0, ',', '$group_desc', '$group_name_name')";
$query_run=mysql_query($query);
if($query_run){
$notification="Successfully created";
}
else {
$notification="Group couldn't be created";
}
}
?>
<html>
<head>
<title>Groups</title>
<style>
.group_name {
margin-bottom:-15px
}
.group_list {
width:20%;
float:left;
margin-top: 50px;
margin-left: 100px;
text-align:center
}
.create_group_form {
width: 40%;
float:right;
margin-top:50px
}
#group_desc_input{
margin-left: -35px
}
</style>
</head>
<body>
<?php
if($_SESSION['email']=="admin@gmail.com"){
?>
<form action="groups.php" method="POST" class="create_group_form">
<h2>Create a group:</h2><br><br>
Name: <input type="text" name="group_name"><br><br>
<span id="group_desc_input">Description: <input type="text" name="group_desc"></span><br><br>
<input type="submit" value="Create" name="group_create"><br>
<?= $notification ?>
</form>
<?php
}
?>
<div class="group_list">
<h2>Groups List</h2>
<?php
$query2=mysql_query("SELECT * FROM groups");
$start_indicator=0;
while($group = mysql_fetch_array($query2)){
if(isset($_POST['delete_group' . $group['group_id']])){
$group_id=$group['group_id'];
$delete_group_query = mysql_query("DELETE from groups WHERE group_id='$group_id'");
header("Refresh:0");
}
$start_indicator++;
?>
<a href="groups/<?= $group['group_name'] ?>">
<h3 class="group_name"><?=$group['name']?></h3>
<p><?= $group['description'] ?></p>
</a>
<?php
if($_SESSION['email']=="admin@gmail.com"){
?>
<form method="POST">
<input type="submit" name="delete_group<?= $group['group_id'] ?>" value="Delete Group">
</form>
<?php
}
?>
<br>
<?php
}
if($start_indicator==0){
echo "<h4>No groups</h4>";
}
?>
</div>
</body>
</html>