-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.php
53 lines (40 loc) · 888 Bytes
/
update.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
<?php
require "layout/header.php";
require "users/users.php";
if (!isset($_GET["id"])) {
require "layout/not_found.php";
exit();
}
$userId = $_GET["id"];
$user = getUserById($userId);
$formErrors = [
"name" => "",
"username" => "",
"email" => "",
"phone" => "",
"website" => "",
];
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$user = array_merge($user, $_POST);
$isvalid = validateUser($user, $formErrors);
if ($isvalid) {
$user = updateUser($_POST, $userId);
if ($_FILES['pircture']["error"] == 0) {
uploadImage($_FILES['pircture'], $user);
}
session_start();
$_SESSION["msg"] = "😊 Updated Successfuly";
header("Location: index.php");
exit();
}
}
if (!$user) {
require "layout/not_found.php";
exit();
}
?>
<div class="update pt-5 pb-5">
<?php include "_form.php" ?>
</div>
<?php
require "layout/footer.php";