-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateProfile.php
More file actions
64 lines (59 loc) · 2.03 KB
/
UpdateProfile.php
File metadata and controls
64 lines (59 loc) · 2.03 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
54
55
56
57
58
59
60
61
62
63
64
<?php
$connection = mysqli_connect("localhost", "root", "", "mytest");
$Encode = file_get_contents('php://input');
$Decode = json_decode($Encode, true);
$username = $Decode['username'];
$category = $Decode['category'];
$name = $Decode["name"];
$password = $Decode["password"];
$phone = $Decode["phone"];
$nid = $Decode["nid"];
$city = $Decode["city"];
$dob = $Decode["dob"];
if($category == 'Customer'){
$query = "UPDATE CustomerTable SET Name='$name', City='$city', Phone='$phone', NID='$nid', Password='$password', DOB='$dob' WHERE Username = '$username';";
$query1 = "UPDATE Login SET Password='$password' WHERE Username = '$username';";
$table = mysqli_query($connection, $query);
$table1 = mysqli_query($connection, $query1);
if($table && $table1){
$message= "Updated!";
echo json_encode($message);
}
else{
$message = "Something wrong!";
echo json_encode($message);
}
}
else if($category == 'Agent'){
$query = "UPDATE AgentTable SET Name='$name', City='$city', Phone='$phone', NID='$nid', Password='$password', DOB='$dob' WHERE Username = '$username';";
$query1 = "UPDATE Login SET Password='$password' WHERE Username = '$username';";
$table = mysqli_query($connection, $query);
$table1 = mysqli_query($connection, $query1);
if($table && $table1){
$message= "Updated!";
echo json_encode($message);
}
else{
$message = "Something wrong!";
echo json_encode($message);
}
}
else if($category == 'Farmer'){
$query = "UPDATE FarmerTable SET Name='$name', City='$city', Phone='$phone', NID='$nid', Password='$password', DOB='$dob' WHERE Username = '$username';";
$query1 = "UPDATE Login SET Password='$password' WHERE Username = '$username';";
$table = mysqli_query($connection, $query);
$table1 = mysqli_query($connection, $query1);
if($table && $table1){
$message= "Updated!";
echo json_encode($message);
}
else{
$message = "Something wrong!";
echo json_encode($message);
}
}
else{
$message = "Something wrong!";
echo json_encode($message);
}
?>