-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmanage_admins.php
More file actions
48 lines (38 loc) · 948 Bytes
/
manage_admins.php
File metadata and controls
48 lines (38 loc) · 948 Bytes
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
session_start();
if(isset($_SESSION['type'])){
if ($_SESSION['type'] != "Administrator"){
header('Location: index.php');
}
} else {
header('Location: index.php');
}
include "models/admin_model.php";
$admins = new AdminForm();
$to_edit = new AdminForm();
if (isset($_POST['add_admin'])){
$to_edit->load_from_post();
$valid = $to_edit->validate();
if ($_POST['password2'] != $to_edit->fields['password']->value){
$valid = false;
} else {
$to_edit->fields['password']->hash_pass();
}
if ($valid){
$to_edit->save();
}
} elseif (isset($_POST['admin_id'])) {
$to_edit->load_by_pk($_POST['admin_id']);
$to_edit->load_from_post();
$valid = $to_edit->validate();
if($valid){
$to_edit->save();
$to_edit = new AdminForm();
}
}
$admins->load_by_filter("");
$page_title = "Manage Administrators";
$panel_heading = "Manage Administrators";
$page_body = "manage_admins_template.php";
include "templates/template.php";
?>