-
Notifications
You must be signed in to change notification settings - Fork 1
/
field_validation.php
92 lines (91 loc) · 2.53 KB
/
field_validation.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
<?php
include 'init.php';
// initialize session
ob_start();
session_start();
session_regenerate_id();
// initialize the var
$response = array(
'status' => 0,
'message' => ""
);
if (!isset($_SESSION['UserEmail'])) {
$response['message'] = lang('no_session');
echo json_encode($response);
exit();
}
$select = $_POST["select"];
$filed = $_POST["filed"];
if (!empty($select) && !empty($filed)) {
//to check from users to loan book
if ($select == 'user') {
$result = get_data(SELECT_LOAN_USER, [$filed]);
if ($result != 0) {
$response['status'] = 1;
$response['message'] = lang('user_have_loan');
echo json_encode($response);
exit();
}else{
$response['status'] = 0;
echo json_encode($response);
exit();
}
}
//check from book title
//to check from part
if ($select == 'book_title') {
$result = get_data(SELECT_BOOK_NAME, [$filed]);
if ($result != 0) {
$response['status'] = 1;
$response['message'] = lang('book_exist');
echo json_encode($response);
exit();
}else{
$response['status'] = 0;
echo json_encode($response);
exit();
}
}
//to check from part
if ($select == 'part') {
$result = get_data(SELECT_LOAN_PART, [$filed]);
if ($result != 0) {
$response['status'] = 1;
$response['message'] = lang('part_have_loan');
echo json_encode($response);
exit();
}else{
$response['status'] = 0;
echo json_encode($response);
exit();
}
}
//to check from part
if ($select == 'publisher') {
$result = get_data(SELECT_PUB_NAME, [$filed]);
if ($result != 0) {
$response['status'] = 1;
$response['message'] = lang('pub_exist');
echo json_encode($response);
exit();
}else{
$response['status'] = 0;
echo json_encode($response);
exit();
}
}
//to check from part
if ($select == 'publisher_seq') {
$result = get_data(SELECT_PUB_SEQ, [$filed]);
if ($result != 0) {
$response['status'] = 1;
$response['message'] = lang('pub_seq_exist');
echo json_encode($response);
exit();
}else{
$response['status'] = 0;
echo json_encode($response);
exit();
}
}
}