-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.php
More file actions
60 lines (56 loc) · 1.47 KB
/
home.php
File metadata and controls
60 lines (56 loc) · 1.47 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
<?php
/**
*
*/
class home
{
protected $db;
public function __construct()
{
include 'libs/db.php';
$this->db = new db();
}
public function PATCH()
{
parse_str(file_get_contents("php://input"),$inputs);
return $inputs;
}
public function GET()
{
return $this->db->fetchAll("Select * from users",[]);
}
public function POST()
{
print_r($_POST);
include 'libs/form.php';
$form = new form();
if($form->check([$_POST["username"],$_POST["password"]])){
return $this->db->fetch("insert into users(username,password) values(?,?)",[$_POST["username"],$_POST["password"]]);
}
return "-1";
}
public function PUT()
{
parse_str(file_get_contents("php://input"),$_POST);
include 'libs/form.php';
$form = new form();
if($form->check([$_POST["id"],$_POST["username"],$_POST["password"]])){
$this->db->fetch("update users set username =?,password=? where user_id = ?",
[$_POST["username"],$_POST["password"],$_POST["id"]]);
return true;
}
return false;
}
public function DELETE()
{
parse_str(file_get_contents("php://input"),$_POST);
include 'libs/form.php';
$form = new form();
if($form->check([$_POST["id"]])){
$this->db->fetch("delete from users where user_id = ?",
[$_POST["id"]]);
return true;
}
return false;
}
}