forked from JoonKai1995/task-sourcing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createNewAdmin.php
96 lines (88 loc) · 3.62 KB
/
createNewAdmin.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
<?php
include("header.php");
$userError="";
if (isset($_POST['submit'])){
$username = $_POST['username'];
$password = $_POST['password'];
$result1 = pg_query($db, 'SELECT MAX(admin_id) FROM administrators');
$old_uid = pg_fetch_result($result1, 0, 0);
$new_uid = $old_uid + 1;
$result2 = pg_query($db, "INSERT INTO administrators values('$new_uid', '$username', '$password')");
if (!$result2) {
$userError = 'Invalid username.';
} else {
echo 'User creation succesful!';
header("Location: adminPage.php");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create A New Admin</title>
</head>
<body>
<div class="fh5co-loader"></div>
<div id="page">
<nav class="fh5co-nav" role="navigation">
<div class="container">
<div class="row">
<div class="col-xs-2 text-left">
<div id="fh5co-logo"><a href="welcome.php">TaskSourcing<span>.</span></a></div>
</div>
<div class="col-xs-10 text-right menu-1">
<ul>
<li class="active"><a href="welcome.php"><i class="icon-home"></i></a></li>
</ul>
</div>
</div>
</div>
</nav>
<header id="fh5co-header" class="fh5co-cover" role="banner" style="background-image:url(images/background.jpg);" data-stellar-background-ratio="0.5">
<div class="overlay"></div>
<div class="container">
<div class="row">
<div class="col-md-7 text-left">
<div class="display-t">
<div class="display-tc animate-box" data-animate-effect="fadeInUp">
<h1 class="mb30">Register</h1>
<form method="post" name="form" action="createNewAdmin.php">
<div class='form-group'>
<label for="inputUser">Username: </label>
<input type="text" name="username" class="form-control" id="inputUser" required>
<span style="color:red"><?php echo $userError;?></span>
</div>
<div class='form-group'>
<label for="inputPassword">Password: </label>
<input type="password" name="password" class="form-control" id="inputPassword" required>
</div>
<input type="submit" name="submit" class="btn btn-primary" value="Create new Admin">
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</header>
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- jQuery Easing -->
<script src="js/jquery.easing.1.3.js"></script>
<!-- Bootstrap -->
<script src="js/bootstrap.min.js"></script>
<!-- Waypoints -->
<script src="js/jquery.waypoints.min.js"></script>
<!-- countTo -->
<script src="js/jquery.countTo.js"></script>
<!-- Magnific Popup -->
<script src="js/jquery.magnific-popup.min.js"></script>
<script src="js/magnific-popup-options.js"></script>
<!-- Stellar -->
<script src="js/jquery.stellar.min.js"></script>
<!-- Main -->
<script src="js/main.js"></script>
</body>
</html>