forked from dbakti7/Parkin-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_user.php
49 lines (38 loc) · 1.32 KB
/
update_user.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
<?php
/*
* Following code will update a product information
* A product is identified by product id (pid)
*/
// array for JSON response
$response = array();
// check for required fields
if (isset($_POST['user_name']) && isset($_POST['name']) && isset($_POST['email'])
&& isset($_POST['phone_number']) && isset($_POST['password'])) {
$user_name = $_POST['user_name'];
$name = $_POST['name'];
$email = $_POST['email'];
$phone_number = $_POST['phone_number'];
$password = $_POST['password'];
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// mysql update row with matched pid
$result = mysql_query("UPDATE userlogin SET name = '$name', email = '$email', phone_number = '$phone_number', password = '$password' WHERE user_name = $user_name");
// check if row inserted or not
if ($result) {
// successfully updated
$response["success"] = 1;
$response["message"] = "User data successfully updated.";
// echoing JSON response
echo json_encode($response);
} else {
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>