-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathendPartnership.php
More file actions
50 lines (46 loc) · 1.44 KB
/
endPartnership.php
File metadata and controls
50 lines (46 loc) · 1.44 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
<?php
require 'dbConnect.php';
if (isset($_REQUEST['id']))
{
$con = makeSQLI();
if($con === false)
die('Error ' . mysqli_connect_error);
$realID = (int)substr(trim($_REQUEST['id']), 2, -3);
$sql = "SELECT * ".
"FROM tb_partner_relation, tb_users ".
"WHERE tb_partner_relation.id = " . $realID . " AND fk_user_id = tb_users.id";
$row;
if($result = $con->query($sql))
{
if(!$row = $result->fetch_array())
die("Non-existant partnership: $realID");
}
else {
die("Error getting partnership information: " . $con->error);
}
$sql = "DELETE FROM tb_partner_relation WHERE id = " . $realID;
if($result = $con->query($sql) && mysqli_affected_rows($con) == 1)
{
$subject = "Project Transparency - Partnership Change";
$message = "We are sorry to inform you that your partnership with " . $row['partner_email_address'] . " per their request. If this was not expected, I would suggest talking to them.";
$someSent = false;
$to = $row['email_address'];
if(mail($to, $subject, $message, 'From: no-response-project@256design.com'))
{
die("Successfully cancelled partnership with ".$to." and they have recieved an email with the following message:</br>".$message);
}
else
{
die("Unsuccessfully sent email. Please make sure your ex-partner is informed.");
}
}
else
{
die("Could not delete partnership. Error: " . $con->error);
}
}
else
{
die("Error with inputted data.");
}
?>