-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanswer_invitation.php
143 lines (53 loc) · 1.7 KB
/
answer_invitation.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
<?php
session_start();
if(!(isset($_SESSION["username"]) && isset($_SESSION["id"]))){
$newURL = "login.php?e=3";
header('Location: '.$newURL);
};
$servername = "localhost";
$username = "stellaa2_costory";
$password = "CSO%YvAwSsTX";
$dbname = "stellaa2_costroy";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$user_id = $_SESSION["id"];
$invite_id = $_GET["i"];
$answer = $_GET["a"];
$sql2 = "SELECT story_id FROM invitations WHERE user_id = '$user_id' AND id = '$invite_id'";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0) {
$row2 = $result2->fetch_array();
$story_id = $row2["story_id"];
if($answer == 2) {
$sql = "UPDATE invitations SET result=2 WHERE id='$invite_id'";
if ($conn->query($sql) === TRUE) {
$newURL = "invitations.php?e=3";
header('Location: '.$newURL);
} else {
//echo "Error updating record: " . $conn->error;
$newURL = "invitations.php?e=4";
header('Location: '.$newURL);
}
} else if($answer == 1) {
$sql = "UPDATE invitations SET result=1 WHERE id='$invite_id'";
if ($conn->query($sql) === TRUE) {
$newURL = "include_user.php?f=1&i=$story_id";
header('Location: '.$newURL);
} else {
//echo "Error updating record: " . $conn->error;
$newURL = "invitations.php?e=6";
header('Location: '.$newURL);
}
} else {
$newURL = "invitations.php?e=1";
header('Location: '.$newURL);
}
} else {
$newURL = "invitations.php?e=2";
header('Location: '.$newURL);
}
?>