-
Notifications
You must be signed in to change notification settings - Fork 1
/
updateList.php
72 lines (57 loc) · 2.04 KB
/
updateList.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();
$selfID = $_SESSION['id'];
include('dbconfig.php');
if(isset($_GET['update_login_status_id'])){
$selfID = $_SESSION['id'];
$last_activity = "UPDATE login_details SET last_activity = now() where userID = $selfID";
mysqli_query($conn, $last_activity);
}
if(isset($_GET['notif_count'])){
$id = $_SESSION['id'];
$notifications = mysqli_query($conn, "SELECT * FROM notificationData WHERE to_userID = $id && seen_status = 0");
$notif_count = $notifications->num_rows;
echo $notif_count;
}
if(isset($_GET['h_id'])){
$hobbieID = mysqli_real_escape_string($conn, $_GET['h_id']);
$existing_row = mysqli_query($conn, "SELECT * from hobbieData where userID = $selfID AND hobbie_ID = $hobbieID");
if(mysqli_num_rows($existing_row) == 0 && mysqli_query($conn, "INSERT INTO `hobbieData` (`userID`, `hobbie_ID`) VALUES ($selfID, $hobbieID)")){
echo "canAdd";
}
else{
echo "Already added!";
}
}
if(isset($_GET['h_delete_id'])){
$remove_id = mysqli_real_escape_string($conn, $_GET['h_delete_id']);
$delete_query = "DELETE FROM hobbieData WHERE userID = $selfID AND hobbie_ID = $remove_id";
if(mysqli_query($conn, $delete_query)){
echo "Deleted!";
}
else{
echo "Couldn't Delete!";
}
}
///////
if(isset($_GET['g_id'])){
$goalID = mysqli_real_escape_string($conn, $_GET['g_id']);
$existing_row = mysqli_query($conn, "SELECT * from goalData where userID = $selfID AND goal_ID = $goalID");
if(mysqli_num_rows($existing_row) == 0 && mysqli_query($conn, "INSERT INTO `goalData` (`userID`, `goal_ID`) VALUES ($selfID, $goalID)")){
echo "canAdd";
}
else{
echo "Already added!";
}
}
if(isset($_GET['g_delete_id'])){
$remove_id = mysqli_real_escape_string($conn, $_GET['g_delete_id']);
$delete_query = "DELETE FROM goalData WHERE userID = $selfID AND goal_ID = $remove_id";
if(mysqli_query($conn, $delete_query)){
echo "Deleted!";
}
else{
echo "Couldn't Delete!";
}
}
?>