-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_group.php
74 lines (70 loc) · 2.56 KB
/
add_group.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
ob_start();
$page_title = 'Add Group';
require_once('includes/load.php');
// Checkin What level user has permission to view this page
page_require_level(1);
?>
<?php
if(isset($_POST['add'])){
$req_fields = array('group-name','group-level');
validate_fields($req_fields);
if(find_by_groupName($_POST['group-name']) === false ){
$session->msg('d','<b>Sorry!</b> Entered Group Name already in database!');
redirect('add_group.php', false);
}elseif(find_by_groupLevel($_POST['group-level']) === false) {
$session->msg('d','<b>Sorry!</b> Entered Group Level already in database!');
redirect('add_group.php', false);
}
if(empty($errors)){
$name = remove_junk($db->escape($_POST['group-name']));
$level = remove_junk($db->escape($_POST['group-level']));
$status = remove_junk($db->escape($_POST['status']));
$query = "INSERT INTO user_groups (";
$query .="group_name,group_level,group_status";
$query .=") VALUES (";
$query .=" '{$name}', '{$level}','{$status}'";
$query .=")";
if($db->query($query)){
//sucess
$session->msg('s',"Group has been creted! ");
redirect('add_group.php', false);
} else {
//failed
$session->msg('d',' Sorry failed to create Group!');
redirect('add_group.php', false);
}
} else {
$session->msg("d", $errors);
redirect('add_group.php',false);
}
}
?>
<?php include_once('layouts/header.php'); ?>
<div class="login-page">
<div class="text-center">
<h3>Add new user Group</h3>
</div>
<?php echo display_msg($msg); ?>
<form method="post" action="add_group.php" class="clearfix">
<div class="form-group">
<label for="name" class="control-label">Group Name</label>
<input type="name" class="form-control" name="group-name">
</div>
<div class="form-group">
<label for="level" class="control-label">Group Level</label>
<input type="number" class="form-control" name="group-level">
</div>
<div class="form-group">
<label for="status">Status</label>
<select class="form-control" name="status">
<option value="1">Active</option>
<option value="0">Deactive</option>
</select>
</div>
<div class="form-group clearfix">
<button type="submit" name="add" class="btn btn-info">Update</button>
</div>
</form>
</div>
<?php include_once('layouts/footer.php'); ?>