cURL post php to remote server yields an empty array -


i want pass array or variable using curl , post remote server , echo contents of array or value of variable. seems simple enough. have been scouring internets in search of solution , i'm 90% sure problem lies somewhere between keyboard , chair i'm here post code,which mess due troubleshooting code added still simple enough figure out easily.

i have tried searching curl post remote server, server receiving empty database, , various combinations of info.

to code; on server , sending remote server.

/*  * data submitted remote url  *  *$_post['key'] = "foo";  */   $post_array = array("mahesh","chari");   // have tried both of these   // $post_array = array('fname'=>'mahesh','lname'=>'chari');   /*  * initialize curl , connect remote url  * need replace url own server's url  * or wherever uploaded script to.  */   $ch = curl_init();  curl_setopt($ch, curlopt_url, 'http://www.5thandpenn.com/worms/curlpost_hanlder.php' );   /*  * instruct curl regular http post  */   curl_setopt($ch, curlopt_post, true);   /*  * specify data posted  */   curl_setopt($ch, curlopt_postfields, $post_array);   /*   * tell curl_exec return response output string  */   curl_setopt($ch, curlopt_returntransfer, true);   /**  * execute curl session  */   $response = curl_exec($ch );   /**  * close curl session , file  */   curl_close($ch );   echo $response; // welcome maheshchari. 

the response on local server is: welcome website string(6) "mahesh" string(5) "chari" string(0) "" string(0) "" null null

so can see correct data being sent remote server , return transfer catching , replying.

the code on remote server this:

$site='website ';  $firstname = 'text';  $firstname = isset($_post['fname']) ? $_post['fname'] : '';  $lastname= isset($_post['lname']) ? $_post['lname'] : '';  $array = array($_post[0], $_post[1]);  // $firstname=$_post[0];  // $lastname=$_post[1];  echo "welcome ";  echo $firstname;  echo $lastname;  echo $site;  print $firstname;  var_dump($array[0]);  var_dump($array[1]);  var_dump($firstname);  var_dump($lastname);  var_dump($post_array);  var_dump($post_array['fname']);  echo htmlspecialchars($_post["fname"]); 

the response remote server is: welcome website null null string(0) "" string(0) "" null null

so here can see remote server not getting variables because null or string(0)

remote server php version: 5.6.17 on linux

php version on local server is: 5.6.10 on mamp

i know proper info being sent , being returned return-transfer local server.

i know remote server not receiving data @ least not php script assume data being stripped somewhere along line.

why remote server receiving null , empty array echo works fine on local server , importantly how can fix work?

the end goal imbed echo call html page on remote server , reflect being sent remote server local server.

i have tried http https, www , no www in url. have tried many different variations of code should work nut nothing work. remote server not allowing data in allow data returned because local host can echo return-transfer , data there.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -