PHP - I Can't get the $_POST Values on Ajax Request
I want to share these posts with you because when I was working on native PHP and Ajax Post request(Specially AngularJS Post request) at that time I can't get a Post value on the form to submit. That's why I would like to share this post. I also want to tell you i was working on my Ubuntu 14.04. I did try a lot but I can't get value.
At last find stuff on how to solve this issue, I did use "file_get_contents('php://input')" that way I could get the POST value in a JSON object and I also decode json value using "json_decode()". So let's try this way :
$post = file_get_contents('php://input');
$post = json_decode($post);
$sql = "INSERT INTO items (title) VALUES ('".$post->title."')";
$result = $mysqli->query($sql);
I hope it can help you...
We are Recommending you
- How to Get All Dates Between Two Dates in PHP?
- How to Get Full Day Name from Date in PHP?
- How to Subtract Hours from DateTime in PHP?
- PHP Add Hours to Datetime Example
- How to Add Year to Date in PHP?
- PHP Curl PUT Request Example Code
- PHP Curl POST Request with Headers Example
- PHP curl post request with parameters and get json response
- PHP Codeigniter - Ajax Infinite Scroll Pagination Example
- PHP - Getting Started PHPUnit test with simple example
- How to remove white space from string in PHP?
- How to get php.ini file path?
- How to use Google Maps API with JQuery PHP?