-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.php
97 lines (89 loc) · 2.33 KB
/
action.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
//action.php
include('config.php');
if(isset($_POST["action"]))
{
if($_POST["action"] == 'insert')
{
$form_data = array(
'name' => $_POST['name'],
'mobile' => $_POST['mobile'],
'message' => $_POST['message'],
'status' => $_POST['status']
);
$api_url = API_ADDRESS . "gsm_api.php?action=insert";
$client = curl_init($api_url);
curl_setopt($client, CURLOPT_POST, true);
curl_setopt($client, CURLOPT_POSTFIELDS, $form_data);
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($client);
curl_close($client);
$result = json_decode($response, true);
// echo ($response);
// exit();
foreach($result as $keys => $values)
echo $result[$keys];
{
if($result[$keys]['success'] == '1')
{
echo 'insert';
}
else
{
//echo 'error';
//print_r($result);
}
}
}
if($_POST["action"] == 'fetch_single')
{
$id = $_POST["id"];
$api_url = API_ADDRESS . "gsm_api.php?action=fetch_single&id=".$id.""; //change this url as per your folder path for api folder
$client = curl_init($api_url);
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($client);
echo $response;
}
if($_POST["action"] == 'update')
{
$form_data = array(
'name' => $_POST['name'],
'mobile' => $_POST['mobile'],
'message' => $_POST['message'],
'status' => $_POST['status'],
'id' => $_POST['hidden_id']
);
$api_url = API_ADDRESS . "gsm_api.php?action=update"; //change this url as per your folder path for api folder
$client = curl_init($api_url);
curl_setopt($client, CURLOPT_POST, true);
curl_setopt($client, CURLOPT_POSTFIELDS, $form_data);
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($client);
curl_close($client);
$result = json_decode($response, true);
foreach($result as $keys => $values)
{
if($result[$keys]['success'] == '1')
{
echo 'updated';
}
else
{
// print_r($result);
exit($response);
// echo 'error keys: ' . $keys;
echo 'error 222 $values: ' . $values;
}
}
}
if($_POST["action"] == 'delete')
{
$id = $_POST['id'];
$api_url = API_ADDRESS . "gsm_api.php?action=delete&id=".$id."";
$client = curl_init($api_url);
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($client);
echo $response;
}
}
?>