-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.php
53 lines (27 loc) · 853 Bytes
/
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
<?php
if ( is_ajax() ) {
$action = isset($_POST["action"]) ? $_POST["action"] : $_GET["action"];
if ( ! empty($action) ) { // Checks if action value exists
switch ($action){ // Switch case for value of action
case "contato":
default:
formDemo();
break;
}
}
};
// Function to check if the request is an AJAX request
function is_ajax() {
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
/*
* Criar integração com base de dados e retornar para o .js conforme as configurações abaixo;
*/
function formDemo (){
/*
* Implementação com o bd
*/
$return['status'] = 'success'; // accept custom style ['success', 'error', 'warning', 'info']
// $return['message'] = '<b>Keep calm</b> is ok!';
echo json_encode( $return );
}