forked from rpiambulance/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.get_if_admin.php
36 lines (27 loc) · 1019 Bytes
/
.get_if_admin.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
<?php
require_once '.db_config.php';
if(!isset($_GET['session_id'])) {
http_response_code(400);
} else {
$connection = new PDO("mysql:host=$dhost;dbname=$dname", $duser, $dpassword);
include ".functions.php";
$user = getUser($_GET['session_id'], $connection);
$username = $user['username'];
if(!isset($username)) {
echo json_encode(array("admin" => false, "scheduling_coordinator" => false));
} else {
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if(!isset($dname)) {
$dname = 'ambulanc_web';
}
// Selecting Database
//$db = mysql_select_db("$dname", $connection);
$connection->exec("USE `$dname`");
$statement=$connection->prepare("SELECT username, admin, schedco FROM members WHERE username = :username");
$statement->bindParam(':username', $username);
$statement->execute();
$results=$statement->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($results[0]);
}
}
?>