-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.php
More file actions
51 lines (47 loc) · 1.46 KB
/
process.php
File metadata and controls
51 lines (47 loc) · 1.46 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
<?php
if(isset($_POST['login'])){
$user_name = $_POST['user_name'];
$password = $_POST['password'];
$myfile = file_get_contents("files/user.json");
$json = json_decode($myfile, true);
foreach ($json as $val) {
if($val['user_name'] == $user_name
&& $val['password'] == $password) {
echo "Welcome ". $user_name;
}
}
}
if(isset($_POST['forgot'])){
$user_name = $_POST['user_name'];
$password = $_POST['password'];
$myfile = file_get_contents("files/user.json");
$json = json_decode($myfile, true);
foreach ($json as &$val) {
if($val['user_name'] == $user_name){
$val['password'] = $password;
}
echo "Updated ". $user_name;
}
file_put_contents("files/user.json",json_encode($json));
}
if(isset($_POST['register'])){
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$user_name = $_POST['user_name'];
$dob = $_POST['dob'];
$password = $_POST['password'];
//Data array to save
$data_array=[
'first_name' =>$first_name,
'last_name' =>$last_name,
'user_name' =>$user_name,
'dob'=>$dob,
'password'=>$password
];
// $myfile = fopen("files/user.json", "w");
// fwrite($myfile, json_encode($data_array));
// fclose($myfile);
file_put_contents("files/user.json",json_encode($data_array));
echo $first_name . $last_name . $dob . $user_name . $password;
}
?>