forked from tylerhall/Shine
-
Notifications
You must be signed in to change notification settings - Fork 1
/
user-new.php
70 lines (63 loc) · 2.31 KB
/
user-new.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
<?PHP
require 'includes/master.inc.php';
$Auth->requireAdmin('login.php');
if(isset($_POST['btnCreateAccount']))
{
$Error->blank($_POST['username'], 'Username');
$Error->blank($_POST['password'], 'Password');
$Error->blank($_POST['level'], 'Level');
$Error->email($_POST['email']);
if($Error->ok())
{
$u = new User();
$u->username = $_POST['username'];
$u->email = $_POST['email'];
$u->level = $_POST['level'];
$u->setPassword($_POST['password']);
$u->insert();
redirect('users.php');
}
else
{
$username = $_POST['username'];
$email = $_POST['email'];
$level = $_POST['level'];
}
}
else
{
$username = '';
$email = '';
$level = 'user';
}
?>
<?PHP include('inc/header.inc.php'); ?>
<div id="bd">
<div id="yui-main">
<div class="yui-b"><div class="yui-g">
<?PHP echo $Error; ?>
<div class="block">
<div class="hd">
<h2>Create new user</h2>
</div>
<div class="bd">
<form action="user-new.php" method="post">
<p><label for="username">Username</label> <input type="text" name="username" id="username" value="<?PHP echo $username; ?>" class="text"></p>
<p><label for="password">Password</label> <input type="password" name="password" id="password" value="" class="text"></p>
<p><label for="email">Email</label> <input type="text" name="email" id="email" value="<?PHP echo $email; ?>" class="text"></p>
<p><label for="level">Level</label>
<select name="level" id="level">
<option <?PHP if($level == 'user') echo 'selected="selected"'; ?> value="user">User</option>
<option <?PHP if($level == 'admin') echo 'selected="selected"'; ?> value="admin">Admin</option>
</select>
</p>
<p><input type="submit" name="btnCreateAccount" value="Create Account" id="btnCreateAccount"></p>
</form>
</div>
</div>
</div></div>
</div>
<div id="sidebar" class="yui-b">
</div>
</div>
<?PHP include('inc/footer.inc.php'); ?>