PHP - I Can't get the $_POST Values on Ajax Request

By Hardik Savani May 14, 2024 Category : PHP

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 :

Solution:

<?php

$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...

Tags :
Shares