-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalid.php
More file actions
66 lines (57 loc) · 1.27 KB
/
Copy pathvalid.php
File metadata and controls
66 lines (57 loc) · 1.27 KB
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
<?php
include 'dbfunction.php';
/**
*Author:Nilesh
*Date:15/3/2018
*
*/
header('location: index.php');
function validatedata($data)
{
$error = 0;
foreach ($data as $key => $value) {
if (empty($value)) {
$error = 1;
}else{
$value = filter_var($value, FILTER_SANITIZE_STRING);
}
}
if ($error == 0) {
return $data;
}else {
return "Please Fill the Data";
}
}
if($_POST['submit']){
if (!empty($_POST['id'])) {
$data = array("id" => $_POST['id'],
"emp_name" => $_POST['emp_name'],
"adress" => $_POST['address'],
"post" => $_POST['post']);
$validatevalue = validatedata($data);
if(is_array($validatevalue)){
$status = update($validatevalue);
if ($status === 1) {
header('location: index.php');
}else{
header('location: index.php');
}
}else{
header('location: index.php');
}
} else {
$data = array("emp_name" => $_POST['emp_name'],
"adress" => $_POST['address'],
"post" => $_POST['post']);
$validatevalue = validatedata($data);
if(is_array($validatevalue)){
$status = insert($validatevalue);
if ($status > 0) {
header('location: index.php');
}
}else{
header('location: index.php');
}
}
}
?>