-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendreq.php
More file actions
62 lines (46 loc) · 1.61 KB
/
Copy pathsendreq.php
File metadata and controls
62 lines (46 loc) · 1.61 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
57
58
59
60
61
62
<?php
//check if for the same user there already is request sent
session_start();
if (isset($_SESSION['namm']) || isset($_SESSION['idd'])){
$sentTo = (int)$_POST['uuuid'];
//dont know why but $sentTO not working
//echo $sentTo;
//insert the id into 'request_from' in the 'request' table for the 'userid'
//(which is the user logged in whose id is stored in session
$id = $_SESSION['idd'];
$tme = date("Y-m-d H:i:s");
include 'connection.php';
//check if he is sending request to own self
if ($sentTo == $_SESSION['idd']){
echo 'own';
}
else{
$sql2 = "SELECT * FROM `relatn` WHERE `uid` ='" . $id . "' && person_id ='" . $sentTo . "'";
$result2 = mysqli_query($con,$sql2) or die(mysqli_error($con));
$rooow = mysqli_fetch_array($result2);
$sql1 = "SELECT * FROM `requests` WHERE `user_id` ='" . $sentTo . "' && `request_from` ='" . $id . "'";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
$roow = mysqli_fetch_array($result1);
if ($rooow){
echo 'al';
}
elseif ($roow){
echo 're';
}
else{
$sql = "INSERT INTO `requests`".
"(user_id, request_from, action, date)".
"VALUES".
"('$sentTo','$id',0,'$tme')";
mysqli_query($con,$sql) or die(mysqli_error($con));
//remove the entry from the suggestion table
//instead of the person_id and uid work with the suggestion id
$sqlDeletn = "DELETE FROM `suggestions` WHERE `uid` = '" . $id .
"' AND `person_id` = '" . $sentTO . "'";
//echo $sqlDeletn;
mysqli_query($con,$sqlDeletn) or die(mysqli_error($con));
echo 'yes';
}
}
}
?>