-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_privilege.php
68 lines (52 loc) · 2.02 KB
/
create_privilege.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
<?php
$title = 'create new privilege user';
$link_css = "'css/form.css'";
include("./partials/db.php");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$name = "";
$privilege = "";
$error = false;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$privilege = $_POST['privilege'];
if (!empty($name) && !empty($privilege)) {
$statement = $pdo->prepare("INSERT INTO type (name_privilege, privilege) VALUES (:name, :privilege)");
$statement->bindValue(':name', $name);
$statement->bindValue(':privilege', $privilege);
$statement->execute();
header("location:show.php");
} else $error = true;
}
?>
<!DOCTYPE html>
<html lang="en">
<?php include("./partials/head.php");
?>
<body>
<header class="blue">
<?php include("./partials/nav.php") ?>
</header>
<body>
<div class="container">
<?php if ($error) : ?>
<div class="alert alert-danger alert-width" role="alert">
<p>Insert all the imputs</p>
</div>
<?php endif ?>
<div class="form">
<form method="POST" enctype="multipart/form-data">
<h2 class="title">Create privilege</h2>
<div class="input-container ic2">
<input type="text" name="name" id="name" class="input" placeholder=" " required>
<div class="cut"></div><label for="nome" class="placeholder">privilege name</label>
</div>
<div class="input-container ic2">
<input type="number" name="privilege" id="privilege" class="input" placeholder="privilege level " min="1" required> <label for="surname"></label>
</div>
<button type="text" class="submit">submit</button>
</form>
</div>
</div>
<?php include("partials/js-bs.html"); ?>
</body>
</html>