input post empty |
Hi guys,
i'm writing a backend in CI (frontend separated in html/js) when i tried to send POST data to my controller $_POST is empty.. I've tried for few way but i always receive a empty array. Maybe the problem could be about htaccess??? tried to call my API Code: http://mysite.com/users/register_post_user id=test email=[email protected] tried already to set url with or without / at the end my controller - Users.php - PHP Code: public function register_post_user() Code: Array ( ) i'm sending request by Postman and my frontend. the result doesn't change. here my - .htacces - (modified only for removing index.php) Code: RewriteEngine on
which js frawework you are using for posting? As I remember I had similar using when I used Angularjs.
Try
PHP Code: $_POST = json_decode(file_get_contents("php://input"), true); Or if it's not json you're sending without the json_decode
You're showing how you check if the vars were received, but not how you actually make the request.
We need to see your JavaScript code on how you are sending the data etc;
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
my js function
Code: function sendLogin(id, email) { the frontend is hosted in another space (app, localhost, another server) so i set the header in my controllers for accepting external request with PHP Code: header('Access-Control-Allow-Origin: *'); could be the .htaccess ? -------- UPDATE ----------- sending data by GET it works. example my request Code: http://mysite.com/users/register_post_user/?id=5890459084523908&email=testemail the result is Code: Array ( [id] => 5890459084523908 [email] => testemail ) tested by URL in browser directly and by Postman....
js:
Code: function sendLogin(id, email) { PHP: Code: public function register_post_user() (10-20-2017, 09:24 AM)ivantcholakov Wrote: js: It works!!! thank you! |
Welcome Guest, Not a member yet? Register Sign In |