I am working on simple API and need to use PUT for updating the values in database. I am not able to sent data from the REST client (postman). The following is the code.
switch ($method) {
case 'GET':
$sql = "select * from trainsample";
break;
case 'PUT':
$sql = "UPDATE trainsample SET Name = $_PUT[Name] WHERE ID = $_PUT[ID] ";
break;
case 'POST':
$sql = "INSERT INTO trainsample VALUES ('$_POST[ID]','$_POST[Name]','$_POST[Place]','$_POST[Data]')";
break;
case 'DELETE':
$sql = "DELETE FROM trainsample WHERE ID = $_DELETE[ID]";
break;
}
The GET and POST are working fine. But not able to perform PUT and DELETE. Any help is appreciated. Thank you in advance.