-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit_post.php
More file actions
53 lines (43 loc) · 1.54 KB
/
Copy pathsubmit_post.php
File metadata and controls
53 lines (43 loc) · 1.54 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
<?php
//include libraries
include_once('lib/database.class.php');
include_once('lib/report.class.php');
$db = new database();
$report = new report($db->getConn());
$errors = array(); // array to hold validation errors
$data = array(); // array to pass back data
if (!empty($errors)) {
// if there are items in our errors array, return those errors
$data['success'] = false;
$data['errors'] = $errors;
} else {
// if there are no errors process our form, then return a message
//Title, UserID, Severity, Status, PostDate
//Table: reporrtitle
$report->title = $_POST['title'];
$report->userid = "1";
$report->severity = $_POST['severity'];
$report->status = $_POST['status'];
$report->incidentdate = $_POST['incidentdate'] ;
//Activate method
$report->insert();
//textarea and postid
$report->textarea = $_POST['textarea'];
$report->insertTextArea();
//Insert tags
/*
* How Tagging Table Work:
* upon submission of title (getID)
* then insert tags in a foreach loop in tags table, for each insert of tag (getID)
* inside TagMap table, input ID's of title and tag table.
*/
$tags = $_POST['tags']; //{str1, str2, str3}
$tags = explode(",",$tags); //explode each string from {}
$report->tags = $tags; //insert tag in method
$report->insertTags(); //execute insert
$data['success'] = true;
$data['message'] = 'Success!';
}
// return all our data to an AJAX call
echo json_encode($data);
?>