-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsendNews.php
More file actions
62 lines (44 loc) · 1.44 KB
/
Copy pathsendNews.php
File metadata and controls
62 lines (44 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
51
52
53
54
55
56
57
58
59
60
61
62
<?php
include_once"cbumobileConnection.php";
$newstitle=$_GET['newsTitle'];
$newsdetails=$_GET['newsDetail'];
$newsDate=$_GET['newsDate'];
$newsImage="Blank";
$newsTitle=filter_var($newstitle, FILTER_SANITIZE_STRING);
$newsDetails=filter_var($newsdetails, FILTER_SANITIZE_STRING);
$setNews="INSERT INTO `cbumobile`.`news` (
`NewsId` ,
`NewsTitle` ,
`Details` ,
`Date` ,
`NewsImage`
)
VALUES (
NULL , '$newsTitle', '$newsDetails', '$newsDate', 'Nill'
)";
if(isset($newsTitle) && isset($newsDetails) && isset($newsDate) && isset($newsImage)){
$sendnews=mysqli_query($connection,$setNews);
if(isset($sendnews)){
$status="Success";
$message="News Has been stored successfully";
sendFeedBack($status,$message);
}else{
$status="Fail";
$message="Failed to store news, try again.";
sendFeedback($status, $message);
}#ends inner if statement
}else{
$status="Fail";
$message="Please complete the news.";
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));
}
?>