PHP – I Can’t get the $_POST Values on Ajax Request

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Hello , Today now in this post I want to share with you because when i was working on native PHP and with Ajax Post request(Specially AngularJS Post request) at that time i can’t get the Post value on form submit. So on that’s why i would like to share with you this post. I also want to tell you what i was working on my Ubuntu 14.04.So I did try lot but i can’t get value.

So at last find stuff to how to solve this issue, i did use “file_get_contents(‘php://input’)” so that way i could get POST value in json object and now i also can decode json value by using “json_decode()”.

So let’s try this way :

Example:

$post = file_get_contents('php://input');
$post = json_decode($post);
$sql = "INSERT INTO items (title) VALUES ('".$post->title."')";
$result = $mysqli->query($sql);

Read Also : How to Create Custom Blade Directive in Laravel?

Thanks for read. I hope it help you. For more you can follow us on facebook.

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →