-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheditProfile.php
More file actions
53 lines (42 loc) · 1.24 KB
/
Copy patheditProfile.php
File metadata and controls
53 lines (42 loc) · 1.24 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
<?php
// Start the session
session_start();
$fileContent = file_get_contents("users");
$userList = json_decode($fileContent, true);
$currentUser;
$otherUsers = array();
foreach ($userList as $user){
if($user["id"] == $_SESSION["userId"]) {
$currentUser = $user;
}
else{
array_push($otherUsers, $user);
}
}
if($currentUser != null){
if(isset($_POST["user"]) && $_POST["user"] != ""){
$currentUser["user"] = $_POST["user"];
$_SESSION["userName"] = $currentUser["user"];
}
if(isset($_POST["newPass1"]) && $currentUser["pass"] == $_POST["oldPass"]){
$currentUser["pass"] = $_POST["newPass1"];
}
if(isset($_POST["email"]) && $_POST["email"] != ""){
$currentUser["email"] = $_POST["email"];
$_SESSION["email"] = $currentUser["email"];
}
array_push($otherUsers, $currentUser);
$filehandle = fopen("users","w");
fwrite($filehandle, json_encode($otherUsers));
fclose($filehandle);
}
?>
<div>
<p>Changes are now saved</p>
<p>You will be redirected to main page after 5 seconds</p>
</div>
<script type="application/javascript">
setTimeout(function () {
window.location.href= 'main.php'; // the redirect goes here
},5000);
</script>