-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_user.php
More file actions
111 lines (104 loc) · 4.8 KB
/
Copy pathadd_user.php
File metadata and controls
111 lines (104 loc) · 4.8 KB
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
111
<?php
include_once 'connection/checkUser.php';
include_once 'database/User.php';
include_once 'database/Database.php';
include_once 'parts/header.php';
$err = '';
//Check if post back
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$err = User::testNew();
}
if (($_SERVER["REQUEST_METHOD"] == "POST") && empty($err)) {
User::newUser($_POST['username'], $_POST['password'], $_POST['name'], $_POST['auth']);
$success = 'User '.$_POST['username'].' has been created.';
header('Location: add_user.php');
} else {
?>
<body>
<div id="wrapper">
<?php include_once 'parts/nav.php'; ?>
<!-- Page Content -->
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Add User</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="panel panel-default">
<div class="panel-heading">
Information
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-6">
<form role="form" method="POST"
action=<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>>
<?php if (!empty($err)) { ?>
<div class="alert alert-danger" role="alert">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
<?php echo $err ?>
</div>
<?php } ?>
<?php if (!empty($success)) { ?>
<div class="alert alert-success" role="alert">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
<?php echo $success ?>
</div>
<?php } ?>
<div class="form-group">
<label>Username:</label>
<input class="form-control" name="username" type="text"
<?php
if(isset($_POST['username'])) {
echo " value='$_POST[username]'";
}
?>>
</div>
<div class="form-group">
<label>Name:</label>
<input class="form-control" name="name" type="text"
<?php
if(isset($_POST['name'])) {
echo " value='$_POST[name]'";
}
?>>
</div>
<div class="form-group">
<label>Password:</label>
<input class="form-control" name="password" type="password" autocomplete="off">
<div id="messages"></div>
</div>
<div class="form-group">
<label>Confirm Password:</label>
<input class="form-control" name="cpassword" type="password" autocomplete="off">
</div>
<div class="form-group">
<label>Authorization:</label>
<select class="form-control" name="auth">
<option value="1">Admin</option>
<option value="2">Dr.</option>
<option value="3">Nurse</option>
<option value="4">Research</option>
</select>
</div>
<button type="submit" class="btn btn-default">Save</button>
</form>
</div>
</div>
<!-- /.row (nested) -->
</div>
<!-- /.panel-body -->
</div>
</div>
<!-- /.container-fluid -->
</div>
<!-- /#page-wrapper -->
</div>
<!-- /#wrapper -->
<?php
include_once 'parts/bottom.php';
include_once 'parts/footer.php';
} ?>