-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend.php
40 lines (32 loc) · 1.43 KB
/
send.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
<?php
include 'db_connection.php';
session_start();
if(isset($_POST['cancel'])){
header('location:user_messages.php');
}
if(isset($_POST['send'])){
if(isset($_POST['oldMessage'])){
$sendingMessage = $_POST['oldMessage'] . '&break&' . $_SESSION['ID'] . '&break&' . $_POST['message'];
$futureDate=date('Y-m-d', strtotime('+1 year'));
$sql = "INSERT INTO Messages (sender_ID, recipient_ID, message, subject, parent_message_ID, expire_date)
VALUES ($_SESSION[ID], $_POST[recipientID], '$sendingMessage', '$_POST[subject]', $_SESSION[messageID], '$futureDate')";
if ($conn->query($sql) === TRUE) {
//echo "New record created successfully";
header('location:user_messages.php?success=1');
} else {
//echo "Error: " . $sql . "<br>" . $conn->error;
}
}else{
$sendingMessage = $_SESSION['ID'] . '&break&' . $_POST['message'];
$futureDate=date('Y-m-d', strtotime('+1 year'));
$sql = "INSERT INTO Messages (sender_ID, recipient_ID, message, subject, expire_date)
VALUES ($_SESSION[ID], $_POST[recipientID], '$sendingMessage', '$_POST[subject]', '$futureDate')";
if ($conn->query($sql) === TRUE) {
//echo "New record created successfully";
header('location:user_messages.php?success=1');
} else {
//echo "Error: " . $sql . "<br>" . $conn->error;
}
}
}
?>