-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathupdate.php
More file actions
39 lines (31 loc) · 713 Bytes
/
update.php
File metadata and controls
39 lines (31 loc) · 713 Bytes
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
<?php
include 'partials/header.php';
require __DIR__ . '/users/users.php';
if (!isset($_GET['id'])) {
include "partials/not_found.php";
exit;
}
$userId = $_GET['id'];
$user = getUserById($userId);
if (!$user) {
include "partials/not_found.php";
exit;
}
$errors = [
'name' => "",
'username' => "",
'email' => "",
'phone' => "",
'website' => "",
];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$user = array_merge($user, $_POST);
$isValid = validateUser($user, $errors);
if ($isValid) {
$user = updateUser($_POST, $userId);
uploadImage($_FILES['picture'], $user);
header("Location: index.php");
}
}
?>
<?php include '_form.php' ?>