-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPost_user.php
More file actions
85 lines (69 loc) · 2.42 KB
/
Copy pathPost_user.php
File metadata and controls
85 lines (69 loc) · 2.42 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
class Post_user{
private $conn;
private $table='users';
public $username;
public $password;
public $mob;
public $has_key;
public $verified;
public $email;
public $CreatedOn;
public function __construct($db){
$this->conn=$db;
}
public function read(){
$query='SELECT p.email,p.password,p.verified,p.username,p.verified,p.has_key,p.mob,p.CreatedOn
FROM ' .$this->table. ' p ';
$stmt=$this->conn->prepare($query);
$stmt->execute();
return $stmt;
}
public function read_single(){
$query='SELECT p.email,p.password,p.verified,p.username,p.verified,p.has_key,p.mob,p.CreatedOn
FROM ' .$this->table. ' p
WHERE p.email= ? AND p.password= ?
';
$stmt=$this->conn->prepare($query);
$stmt->bindParam(1,$this->email);
$stmt->bindParam(2,$this->password);
$stmt->execute();
return $stmt;
$row=$stmt->fetch(PDO::FETCH_ASSOC);
$this->email=$row['email'];
$this->password=$row['password'];
$this->verified=$row['verified'];
$this->CreatedOn=$row['CreatedOn'];
}
public function create() {
// Create query
$query = 'INSERT INTO ' . $this->table . '
SET
username = :username,
password = :password,
verified = :verified,
mob = :mob,
email = :email,
has_key = :has_key';
// Prepare statement
$stmt = $this->conn->prepare($query);
// Clean data
$this->username=htmlspecialchars(strip_tags($this->username));
$this->password=htmlspecialchars(strip_tags($this->password));
$this->email=htmlspecialchars(strip_tags($this->email));
$this->has_key=htmlspecialchars(strip_tags($this->has_key));
$this->verified=htmlspecialchars(strip_tags($this->verified));
$this->mob=htmlspecialchars(strip_tags($this->mob));
// Bind data
$stmt->bindParam(':username', $this->username);
$stmt->bindParam(':password', $this->password);
$stmt->bindParam(':email', $this->email);
$stmt->bindParam(':has_key', $this->has_key);
$stmt->bindParam(':verified', $this->verified);
$stmt->bindParam(':mob', $this->mob);
// Execute query
if($stmt->execute()) {
return true;
}
}
}