-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_add.php
More file actions
48 lines (34 loc) · 1.26 KB
/
user_add.php
File metadata and controls
48 lines (34 loc) · 1.26 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
<?php
require "db.php";
require "functions.php";
$roles = getRoles($sql);
if(isset($_POST["add"])) {
$is_active = 0;
if(isset($_POST["is_active"])) {
$is_active = 1;
}
$avatar = $_FILES["avatar"]["name"];
move_uploaded_file($_FILES["avatar"]["tmp_name"], "uploads/" . $avatar);
addUser($sql, $_POST["name"], $_POST["email"], $_POST["role_id"], $is_active, $avatar);
header("location: index.php");
exit;
}
require "header.php";
?>
<h1> Add user </h1>
<form method="post" enctype="multipart/form-data">
<input type="text" name="name" placeholder="Users Name">
<input type="email" name="email" placeholder="Users email">
<select name="role_id">
<option value="">Select Role</option>
<?php foreach($roles as $role): ?>
<option value="<?= $role["id"]?>"> <?= $role["name"]?> </option>
<?php endforeach; ?>
<label>
<input type="checkbox" name="is_active" value="1">
User is Active
</label>
<label> Avatar </label>
<input type="file" name="avatar">
<button type="submit" name="add"> ADD </button>
</form>