-
Notifications
You must be signed in to change notification settings - Fork 0
/
proposalProcessor.php
41 lines (31 loc) · 1.25 KB
/
proposalProcessor.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
<?php
require_once 'AndLib/AndCore.php';
session_start();
if (empty($_SESSION['user_id'])) {
$isLogin = false;
header('Location:' . AndPath::getHost() . AndPath::getPath() . '/index.php');
} else{
$isLogin = true;
}
$owner = $_SESSION['user_id'];
$writing_id = $_POST['writing_id'];
$reciever_id = $_POST['reciever_id'];
$proposal = $_POST['proposal'];
$timeNow = date("Y-m-d H:i:s", time());
AndDevDebug::printNice($reciever_id);
// ---------------- handle database ------------------
$con = new AndDatabase();
$result = $con->query("
INSERT INTO `openpen`.`act_marathon_prop` (`writing_id`, `user_proposer`, `prop_text`, `date_prop_created`, `prop_status`)
VALUES ('$writing_id', '$owner', '$proposal', '$timeNow', '0');
");
$broadcaster = $con->query("INSERT INTO `openpen`.`notifications` (`reciever`, `sender`, `activity`, `object_id`, `notif_created`, `notif_status`)
VALUES ('$reciever_id', '$owner', '2', '$writing_id', '$timeNow', '0')
");
if ($result == 1 && $broadcaster == 1) {
$_SESSION['proposal_sent'] = "Konsep Lanjutan Cerita berhasil dikirim";
header('Location:' . AndPath::getHost() . AndPath::getPath() . '/proposal.php?ref=' . $writing_id);
}
$conection->closeConnection();
// ---------------- handle database ------------------
?>