-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_create_user.php
More file actions
64 lines (55 loc) · 1.77 KB
/
Copy pathadmin_create_user.php
File metadata and controls
64 lines (55 loc) · 1.77 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
<?php
require_once 'private_php/p_global.php';
require_once 'private_php/c_create_user.php';
require_once 'private_php/p_html_functions.php';
$error = null;
requireLogin(['administrator']);
if (isset($_POST['action'])) {
$forename = trim($_POST['forename']);
$surname = trim($_POST['surname']);
$email = trim($_POST['email']);
$clubId = $_POST['cid'];
if (!$forename) {
$error = 'Missing forename';
} else if (!$surname) {
$error = 'Missing surname';
} else if (!$email) {
$error = 'Missing email address';
} else if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error = 'Invalid email address';
} else if (!$clubId) {
$error = 'Missing club';
} else {
try {
createUser($forename, $surname, $email, $clubId);
} catch (Exception $ex) {
$error = $ex->getMessage();
}
}
}
pageHeader('Create User');
?>
<h2>Create User</h2>
<?php if ($error) { ?>
<p class="error"><?php echo htmlspecialchars($error); ?></p>
<?php } ?>
<form class="tabForm" enctype="multipart/form-data" method="post"
action="<?php echo htmlspecialchars($_SERVER['SCRIPT_NAME']); ?>">
<p><label for="forename">Forename:</label> <input type="text" name="forename" id="forename" /></p>
<p><label for="surname">Surname:</label> <input type="text" name="surname" id="surname" /></p>
<p><label for="email">Email address:</label> <input type="text" name="email" id="email" /></p>
<p>
<label for="cid">Club:</label>
<select name="cid" id="cid"><?php
renderSelectOption('', $clubID, '');
$stmt = $Database->query('SELECT club_id, name FROM club WHERE status = 1 ORDER BY name');
while ($row = $stmt->fetch()) {
renderSelectOption($row['club_id'], $clubID, $row['name']);
}
?></select>
</p>
<p><input type="submit" name="action" value="Create" /></p>
</form>
<?php
pageFooter();
?>