-
Notifications
You must be signed in to change notification settings - Fork 1
/
joingroup.php
139 lines (134 loc) · 4.89 KB
/
joingroup.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
<?php
include 'dbh.inc.php';
if(isset($_GET['id'])) {
$id = htmlspecialchars($_POST['id'], ENT_QUOTES, 'UTF-8');
$id = mysqli_real_escape_string($conn, $id);
include 'header.php';
if(!isset($_SESSION['email'])) {
header("location: index.php");
exit();
}
$email = $_SESSION['email'];
$fromid = $_SESSION['id'];
$sql = "SELECT * FROM groupmem WHERE email = '$email' AND groupid = '$id'";
$result = $conn->query($sql);
$resultCheck = mysqli_num_rows($result);
if($resultCheck > 0) {
header("location: home.php?alreadyamember");
exit();
}
$id = $_GET['id'];
$sql2 = "SELECT * FROM groups WHERE id = '$id'";
$result2 = $conn->query($sql2);
$resultCheck2 = mysqli_num_rows($result2);
if($resultCheck2 > 0) {
while($row = mysqli_fetch_assoc($result2)) {
$groupname = htmlspecialchars($row['name'], ENT_QUOTES, 'UTF-8');
$groupname = mysqli_real_escape_string($conn, $groupname);
$id = $row['id'];
$date3 = date("Y-m-d");
$date2 = date("H:i:s");
$date4 = $time_in_12_hour_format = date("g:i a", strtotime($date2));
$date = $date3 . " " . $date4;
$altdate = date("H:i:s");
$altdate = $time_in_12_hour_format = date("g:i a", strtotime($date2));
$sql2 = "INSERT INTO wall (fromname, fromid, typewall, noteid, date, altdate) VALUES ('$email', '$fromid', 'Joined Group', '$id', '$date', '$altdate')";
$result2 = $conn->query($sql2);
$sql3 = "INSERT INTO groupmem (fgroup, email, status, groupid) VALUES ('$groupname', '$email', 'member', '$id')";
$result3 = $conn->query($sql3);
header("location: group.php?id=".$id."");
}
} else {
header("location: home.php");
exit();
}
}
if(isset($_GET['gid'])) {
$id = htmlspecialchars($_GET['gid'], ENT_QUOTES, 'UTF-8');
$id = mysqli_real_escape_string($conn, $id);
include 'header.php';
if(!isset($_SESSION['email'])) {
header("location: index.php");
exit();
}
$email = $_SESSION['email'];
$fromid = $_SESSION['id'];
$sql = "SELECT * FROM groupmem WHERE email = '$email' AND groupid = '$id'";
$result = $conn->query($sql);
$resultCheck = mysqli_num_rows($result);
if($resultCheck > 0) {
header("location: home.php");
exit();
}
$id = $_GET['gid'];
$sql2 = "SELECT * FROM groups WHERE id = '$id'";
$result2 = $conn->query($sql2);
$resultCheck2 = mysqli_num_rows($result2);
if($resultCheck2 > 0) {
while($row = mysqli_fetch_assoc($result2)) {
$groupname = htmlspecialchars($row['name'], ENT_QUOTES, 'UTF-8');
$groupname = mysqli_real_escape_string($conn, $groupname);
$id = $row['id'];
$date3 = date("Y-m-d");
$date2 = date("H:i:s");
$date4 = $time_in_12_hour_format = date("g:i a", strtotime($date2));
$date = $date3 . " " . $date4;
$altdate = date("H:i:s");
$altdate = $time_in_12_hour_format = date("g:i a", strtotime($date2));
$sql2 = "INSERT INTO wall (fromname, fromid, typewall, noteid, date, altdate) VALUES ('$email', '$fromid', 'Joined Group', '$id', '$date', '$altdate')";
$result2 = $conn->query($sql2);
$sql3 = "INSERT INTO groupmem (fgroup, email, status, groupid) VALUES ('$groupname', '$email', 'member', '$id')";
$result3 = $conn->query($sql3);
header("location: group.php?id=".$id."");
}
} else {
header("location: home.php");
exit();
}
}
if(isset($_GET['ind'])) {
$id = htmlspecialchars($_POST['id'], ENT_QUOTES, 'UTF-8');
$id = mysqli_real_escape_string($conn, $id);
include 'header.php';
if(!isset($_SESSION['email'])) {
header("location: index.php");
exit();
}
$email = $_SESSION['email'];
$fromid = $_SESSION['id'];
$sql = "SELECT * FROM groupmem WHERE email = '$email' AND groupid = '$id'";
$result = $conn->query($sql);
$resultCheck = mysqli_num_rows($result);
if($resultCheck > 0) {
header("location: home.php?alreadyamember");
exit();
}
$id = $_GET['ind'];
$sql2 = "SELECT * FROM groups WHERE id = '$id'";
$result2 = $conn->query($sql2);
$resultCheck2 = mysqli_num_rows($result2);
if($resultCheck2 > 0) {
while($row = mysqli_fetch_assoc($result2)) {
$groupname = htmlspecialchars($row['name'], ENT_QUOTES, 'UTF-8');
$groupname = mysqli_real_escape_string($conn, $groupname);
$id = $row['id'];
$date3 = date("Y-m-d");
$date2 = date("H:i:s");
$date4 = $time_in_12_hour_format = date("g:i a", strtotime($date2));
$date = $date3 . " " . $date4;
$altdate = date("H:i:s");
$altdate = $time_in_12_hour_format = date("g:i a", strtotime($date2));
$sql2 = "INSERT INTO wall (fromname, fromid, typewall, noteid, date, altdate) VALUES ('$email', '$fromid', 'Joined Group', '$id', '$date', '$altdate')";
$result2 = $conn->query($sql2);
$invite = $_GET['n'];
$sqln = "DELETE FROM invites WHERE id = '$invite'";
$resultn = $conn->query($sqln);
$sql3 = "INSERT INTO groupmem (fgroup, email, status, groupid) VALUES ('$groupname', '$email', 'member', '$id')";
$result3 = $conn->query($sql3);
header("location: group.php?id=".$id."");
}
} else {
header("location: home.php");
exit();
}
}