-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcreatemessage.php
60 lines (51 loc) · 1.2 KB
/
createmessage.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
<?php
error_reporting(0);
//Database Connection
define('INCLUDE_CHECK', true);
require 'connect.php';
//json decode the values recieved
$_POST = json_decode(file_get_contents('php://input'), true);
//Params passed or not
if(!isset($_POST['fromMob'])){
$output = array(
"status" => false,
"error" => "from is not set",
"errorCode" => "102",
"response" => ""
);
die(json_encode($output));
}
if(!isset($_POST['toMob'])){
$output = array(
"status" => false,
"error" => "to is not set",
"errorCode" => "102",
"response" => ""
);
die(json_encode($output));
}
if(!isset($_POST['message'])){
$output = array(
"status" => false,
"error" => "message is not set",
"errorCode" => "102",
"response" => ""
);
die(json_encode($output));
}
//assign the values to local varibles
$fromMob=$_POST['fromMob'];
$toMob=$_POST['toMob'];
$message=$_POST['message'];
mysql_query("INSERT INTO `dash_messages`(`fromMob`, `toMob` , `message`) VALUES ('{$fromMob}','{$toMob}','{$message}')");
$response = array(
"message" => "message was created sucessfully"
);
$output = array(
"status" => true,
"error" => "",
"errorCode" => "",
"response" => $response
);
echo json_encode($output);
?>