-
Notifications
You must be signed in to change notification settings - Fork 1
/
leavegroup.php
43 lines (43 loc) · 1.32 KB
/
leavegroup.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
<?php
include 'dbh.inc.php';
if(isset($_GET['id'])) {
$id = htmlspecialchars($_GET['id'], ENT_QUOTES, 'UTF-8');
$id = mysqli_real_escape_string($conn, $id);
include 'header.php';
$uid = $_SESSION['email'];
$uid = htmlspecialchars($uid, ENT_QUOTES, 'UTF-8');
$uid = mysqli_real_escape_string($conn, $uid);
$sql2 = "SELECT * FROM groups WHERE id = '$id'";
$result2 = $conn->query($sql2);
$resultCheck2 = mysqli_num_rows($result2);
if($resultCheck2 < 0) {
header("location: mygroups.php");
exit();
} else {
$sql = "DELETE FROM groupmem WHERE groupid = '$id' AND email = '$uid'";
$result = $conn->query($sql);
header("location: mygroups.php");
exit();
}
}
include 'dbh.inc.php';
if(isset($_GET['gid'])) {
$id = htmlspecialchars($_GET['gid'], ENT_QUOTES, 'UTF-8');
$id = mysqli_real_escape_string($conn, $id);
include 'header.php';
$uid = $_SESSION['email'];
$uid = htmlspecialchars($uid, ENT_QUOTES, 'UTF-8');
$uid = mysqli_real_escape_string($conn, $uid);
$sql2 = "SELECT * FROM groups WHERE id = '$id'";
$result2 = $conn->query($sql2);
$resultCheck2 = mysqli_num_rows($result2);
if($resultCheck2 < 0) {
header("location: mygroups.php");
exit();
} else {
$sql = "DELETE FROM groupmem WHERE groupid = '$id' AND email = '$uid'";
$result = $conn->query($sql);
header("location: group.php?id=".$id."");
exit();
}
}