I am new to php and API and I am trying to learn the methods. But I am not able to perform PATCH or PUT to update my simple mysql database. I used the following code.
if(isset($_PATCH)){
$con = mysqli_connect("localhost", "root", "root","wordpress");
$sql = "UPDATE trainsample SET Location = ('$_PATCH[Location]'), Data = ('$_PATCH[Data]') WHERE Name = ('$_PATCH[Name]')";
mysqli_query($con,$sql);
echo "Data Updated<br>";
}
else
{
echo "Data Not found ";
}
I am using postman as REST client and try to sent data to update the fields. Any help is appreciated. Thank you in advance.
The following is a fully functional REST server in PHP:
It does:
source
I found a workaround using POST. I am a beginner, if there is a better way please respond.