Welcome i have some JSON data and i want update this in database(I want to use Silm framework but I don't know how). How can I send JSON data to PHP because this:
index.php
<?php
require 'Slim/Slim.php'
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->put('/saveUser/:idUser', function($idUser) {
$user = json_decode(file_get_contents("php://input"));
echo $user->newName.' - '.$user->newEmail;
});
retrun me error
500 (Internal Server Error) Trying to get property of non-object
app.js :
var data = {
idUser: 1,
newName: 'Kaker',
newEmail: 'aa@dd.com'
}
$http.put("app/api/saveUser/" + data.idUser, data);
$app->put('/saveUser/:idUser', function($idUser) use ($app) {
$user = $app->request->put();
echo $user->newName.' - '.$user->newEmail;
});
Try this out :) you can find slim support on IRC, and we have our own forums as well.
Our docs are pretty awesome too http://www.slimframework.com/
Don't be afraid to open issues on our GitHub! https://github.com/slimphp/Slim
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.