-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_edit.php
More file actions
52 lines (37 loc) · 1.41 KB
/
user_edit.php
File metadata and controls
52 lines (37 loc) · 1.41 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
<?php
require "db.php";
require "functions.php";
require "header.php";
$id = $_GET["id"];
$roles = getRoles($sql);
$user = getUser($sql, $id);
if(isset($_POST["edit"])) {
$is_active = 0;
if(isset($_POST["is_active"])) {
$is_active = 1;
}
$avatar = $_FILES["avatar"]["name"];
move_uploaded_file($_FILES["avatar"]["tmp_name"], "uploads/" . $avatar);
editUser($sql, $id, $_POST["name"], $_POST["email"], $_POST["role_id"], $is_active, $avatar);
header("location: index.php");
exit;
}
require "header.php";
?>
<h1> Edit user </h1>
<form method="post" enctype="multipart/form-data">
<input type="text" name="name" value="<?= $user["name"]?>">
<input type="email" name="email" value="<?= $user["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" <?php if($user["is_active"] == 1) echo "checked"; ?>>
User is Active
</label>
<label> Avatar </label>
<input type="file" name="avatar">
<button type="submit" name="edit"> Edit </button>
</form>