-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_functions.php
48 lines (40 loc) · 893 Bytes
/
admin_functions.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_once('config.php');
function create_user()
{
$userM = new User();
$userM->setPassword();
$userM->save();
return $userM->userInfo();
}
/*
recieves and checks post data, start a admin session if value
*/
function verify_admin()
{
$config = new Config();
$conn = $config->getConnection();
$query = "SELECT username,password from admin";
$result = $conn->query($query);
if($result->num_rows > 0)
{
while ($row = $result->fetch_assoc())
{
if($_POST['username'] == $row['username'] && $_POST['password'] == $row['password'])
{
session_start();
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
return TRUE;
}
}
}
return FALSE;
}
/*check whether there is an admin session*/
function admin_logged_in()
{
session_start();
return isset($_SESSION['username']) && isset($_SESSION['password']);
}
?>