-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_cat.php
41 lines (34 loc) · 950 Bytes
/
check_cat.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
<?php
// initialize session
ob_start();
session_start();
session_regenerate_id();
// include required file
require_once 'init.php';
//default response message
$response = array(
'status' => 0,
'message' => lang('no_cat_name')
);
// validate session
if (!isset($_SESSION['UserEmail'])) {
$response['message'] = lang('no_session');
echo json_encode($response);
exit();
}
// validate get param
if (!filter_input(INPUT_POST, 'cat_name', FILTER_SANITIZE_SPECIAL_CHARS)) {
$response['message'] = lang('no_cat_name');
echo json_encode($response);
}
$cat_name = filter_input(INPUT_POST, 'cat_name', FILTER_SANITIZE_SPECIAL_CHARS);
$results = get_data(CHECK_CATEGORY, [$cat_name]);
if ($results != 0) {
$response['message'] = lang('invalid_cat_name');
echo json_encode($response);
exit();
}
//new book inserted
$response['status'] = 1;
$response['message'] = lang('valid_cat_name');
echo json_encode($response);