-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.php
More file actions
executable file
·43 lines (43 loc) · 1020 Bytes
/
Server.php
File metadata and controls
executable file
·43 lines (43 loc) · 1020 Bytes
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
<?php
require 'employee.php';
$_method = $_SERVER['REQUEST_METHOD'];
if($_method =='GET' ){
if($_GET['action']=='delete'){
$emp = new Emp($_GET['id']);
$emp->deleteEmp();
}
elseif($_GET['action'] == 'select'){
$emp = new Emp($_GET['id']);
$jsondata = json_encode($emp);
echo $jsondata;
}
elseif($_GET['action'] == 'draw'){
$emp = new Emp();
$employees= $emp-> employees();
$jsondata = json_encode($employees);
echo $jsondata;
}
}
else{
if (isset($_POST['id'])){
$emp_id = $_POST['id'];
$emp = new Emp($emp_id);
$emp->name = $_POST['name'];
$emp->email = $_POST['email'];
$emp->salary = $_POST['sal'];
$emp->id = $emp->updateEmp();
$jsondata = json_encode($emp);
echo $jsondata;
}
else{
$emp = new Emp();
$emp->name = $_POST['name'];
$emp->email = $_POST['email'];
$emp->salary = $_POST['sal'];
$emp->id = $emp->createEmp();
$employees = new Emp($emp->id);
$jsondata = json_encode($employees);
echo $jsondata;
}
}
?>