-
Notifications
You must be signed in to change notification settings - Fork 1
/
sendEvent.php
69 lines (47 loc) · 1.72 KB
/
sendEvent.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
include_once"cbumobileConnection.php";
#Get events from the application
$eventtitle=urldecode($_GET['eventTitle']);
$eventdescription=urldecode($_GET['eventDescription']);
$eventDate=urldecode($_GET['eventDate']);
$eventvenue=urldecode($_GET['eventVenue']);
$eventTitle=filter_var($eventtitle,FILTER_SANITIZE_STRING);
$eventDescription=filter_var($eventdescription, FILTER_SANITIZE_STRING);
$eventVenue=filter_var($eventvenue, FILTER_SANITIZE_STRING);
#sql insert query to insert event into the database
$setEvent="INSERT INTO `cbumobile`.`events` (
`EventId` ,
`EventTitle` ,
`EventDescription` ,
`Date` ,
`Venue`
)
VALUES (
NULL , '$eventTitle', '$eventDescription', '$eventDate', '$eventVenue'
)";
if(isset($eventTitle) && isset($eventDescription) && isset($eventDate) && isset($eventVenue)){
$sendevent=mysqli_query($connection,$setEvent);
if(isset($sendevent)){
$status="Success";
$message="The event has been stored successfully";
sendFeedBack($status,$message);
}else{
$status="Fail";
$message="Failed to store the event, try again.";
sendFeedback($status, $message);
}#ends inner if statement
}else{
$status="Fail";
$message="Please complete information about the event.";
sendFeedback($status, $message);
}#ends outer if statement
mysqli_close($connection);
function sendFeedBack($status, $message){
#returns the right feedback message
#depending on what has happens
$feedBack['Status']=$status;
$feedBack['Message']=$message;
$sendFeedBack[]=$feedBack;
print(json_encode($sendFeedBack));
}
?>