-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddrole.php
110 lines (74 loc) · 2.34 KB
/
addrole.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
session_start();
if(!$_SESSION['email'])
{
header("Location: login.php");//redirect to login page to secure the welcome page without login access.
}
if(isset($_POST['submit'])){
$data_missing = array();
if(empty($_POST['role_name'])){
$data_missing[] = ' Role Name ';
} else{
$role_name = trim($_POST['role_name']);
}
if(empty($_POST['role_desc'])){
$data_missing[] = ' Role Description ';
} else{
$role_desc = trim($_POST['role_desc']);
}
if(empty($data_missing)){
$connection = mysqli_connect("localhost","root","","hstore");
$query = "INSERT INTO `roles`(`r_name`, `r_desc`) VALUES ('$role_name','$role_desc');";
$result = mysqli_query($connection, $query);
if ($result)
//success
echo "successful";
else
{
die("Database query not working. " . mysqli_error($connection));
}
} else {
echo 'You need to enter the following data<br />';
foreach($data_missing as $missing){
echo "$missing<br />";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Role Management</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="resources/js/script.js" charset="utf-8"></script>
<script src="resources/js/jquery.min.js"></script>
<link rel="stylesheet" href="resources/css/master.css">
</head>
<body>
<header>
<?php include_once 'template/header.php'; ?>
</header>
<div class="container">
<form name="regform" action="addrole.php" method="POST" onsubmit="return validateForm()">
<div class="center">
<h1>Add Role </h1>
</div>
<table class="table table-condensed">
<tr>
<td>Roll Name :</td><td><input type="text" name="role_name" placeholder="Rollname" class="form-control"></td>
</tr>
<tr>
<td>Roll Description :</td><td><input type="blog_descrip" name="role_desc" placeholder="Roll Description" class="form-control"></td>
</tr>
</table>
<div class="right" >
<tr>
<td></td><td><input type="submit" name="submit" value=" Submit " class="btn btn-primary btn-block" ></td>
</tr>
</div>
</form>
</div>
</body>
<?php include_once 'template/footer.php'; ?>
</head>