forked from sergeydgr8/rsta
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_rsvp.php
More file actions
56 lines (49 loc) · 1.58 KB
/
Copy pathprocess_rsvp.php
File metadata and controls
56 lines (49 loc) · 1.58 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
<?php
// error reporting
error_reporting(E_ALL);
ini_set("display_errors", 1);
print_r($_POST);
// mysql information
$cxn = mysqli_connect("warehouse", "sas1030", "ub357uak", "sas1030_assignment_7");
$username = $_POST['username'];
$pin = $_POST['pin'];
$attending = $_POST['attending'];
$eventID = $_POST['event_id'];
$login_query = "SELECT user_id FROM users WHERE user_username=\"{$username}\" AND user_pin=\"{$pin}\"";
$login_result = $cxn->query($login_query);
$login_row = mysqli_fetch_array($login_result);
if (!empty($login_row))
{
$guest_list_query = "SELECT * FROM guest_list WHERE user_id={$login_row['user_id']} AND event_id={$eventID}";
$guest_list_result = $cxn->query($guest_list_query);
$guest_list_row = mysqli_fetch_array($guest_list_result);
if (!empty($guest_list_row))
{
if ($attending == "on")
{
$rsvp_update_query = "UPDATE guest_list SET is_user_going_to_event=1 WHERE user_id={$login_row['user_id']} AND event_id={$eventID}";
}
else
{
$rsvp_update_query = "UPDATE guest_list SET is_user_going_to_event=0 WHERE user_id={$login_row['user_id']} AND event_id={$eventID}";
}
$rsvp_update_result = $cxn->query($rsvp_update_query);
}
else
{
if ($attending == "on")
{
$rsvp_create_query = "INSERT INTO guest_list (event_id, user_id, is_user_going_to_event) VALUES({$eventID}, {$login_row['user_id']}, 1)";
}
else
{
$rsvp_create_query = "INSERT INTO guest_list (event_id, user_id, is_user_going_to_event) VALUES({$eventID}, {$login_row['user_id']}, 0)";
}
}
header("Location:event.php?event_id={$eventID}");
}
else
{
header("Location:rsvp.php");
}
?>