-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminFunctions.php
48 lines (37 loc) · 1.29 KB
/
adminFunctions.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
<?php
include 'admin.php';
//include 'DatabaseConnection.php';
class adminFunctions{
function insertAdmin(admin $newAdmin){
$dbConnection = new DatabaseConnection();
$conn=$dbConnection->connection();
mysqli_set_charset($conn,'utf8');
$userName = $newAdmin->userName;
$password = $newAdmin->password;
$result = $conn->query("CALL `insertAdmin`('$userName', '$password');");
}
function deleteAdmin(admin $newAdmin){
$dbConnection = new DatabaseConnection();
$conn=$dbConnection->connection();
mysqli_set_charset($conn,'utf8');
$userName = $newAdmin->userName;
$password = $newAdmin->password;
$result = $conn->query("CALL `deleteAdmin`('$userName', '$password');");
}
function selectAdminLogin($userName,$password){
$dbConnection = new DatabaseConnection();
$conn=$dbConnection->connection();
mysqli_set_charset($conn,'utf8');
$sql= $conn->query("CALL `selectAdminLogin`('$userName', '$password');");
while($rs = $sql->fetch_array(MYSQLI_ASSOC)) {
$newAdmin = new admin();
$newAdmin->id=$rs['id'];
$newAdmin->userName=$rs['userName'];
$newAdmin->password=$rs['password'];
$admins[]=$newAdmin;
}
$conn->close();
return json_encode($admins,JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);
}
}
?>