forked from grimelinse/FOS-Streaming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_admin.php
43 lines (37 loc) · 1.1 KB
/
manage_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
37
38
39
40
41
42
43
<?php
include('config.php');
logincheck();
$message = [];
$title = "Create admin";
$admin = new Admin;
if(isset($_GET['id'])) {
$title = "Edit admin";
$admin = Admin::where('id', '=', $_GET['id'])->first();
}
if (isset($_POST['submit'])) {
$admin->username = $_POST['username'];
if($_POST['password'] != "") {
$admin->password = md5($_POST['password']);
}
if(isset($_GET['id'])) {
$message['type'] = "success";
$message['message'] = "admin edited";
$admin->save();
} else {
$exists = Admin::where('username', '=', $_POST['username'])->get();
if(count($exists) > 0) {
$message['type'] = "error";
$message['message'] = "admin name already exists";
} else {
$message['type'] = "success";
$message['message'] = "admin Created";
$admin->save();
redirect("manage_admin.php?id=" . $admin->id, 2000);
}
}
}
echo $template->view()->make('manage_admin')
->with('admin', $admin)
->with('message', $message)
->with('title', $title)
->render();