-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-update.php
More file actions
25 lines (18 loc) · 782 Bytes
/
api-update.php
File metadata and controls
25 lines (18 loc) · 782 Bytes
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
<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: PUT');
header('Access-Control-Allow-Headers: Access-Control-Allow-Headers,Content-Type, Access-Control-Allow-Methods, Authorization, X-Requested-With');
$data = json_decode(file_get_contents("php://input"), true);
$id = $data['sid'];
$name = $data['sname'];
$age = $data['sage'];
$city = $data['scity'];
include "config.php";
$sql = "UPDATE students SET student_name = '{$name}', age = {$age}, city = '{$city}' WHERE id = {$id}";
if(mysqli_query($conn, $sql)){
echo json_encode(array('message' => 'Student Record Updated.', 'status' => true));
}else{
echo json_encode(array('message' => 'Student Record Not Updated.', 'status' => false));
}
?>