A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By Almador
#33556 Hi guys, i need your help.

I need to receive POST data on the ESP8266.
If i use a simple HTML form to send the data to the ESP, there is no problem i can get them with:
Code: Select all void testausgabe(){
   String data;
     for (uint8_t i=0; i<server.args(); i++){
       data += " " + server.argName(i) + ": " + server.arg(i) + "\n";
     }
     if(data != lastdata){
     Serial.println(data);
   }
   lastdata = data;
 }

but i have to send the POST-data without a HTML form, so i used PHP cURL for a trial like this:
Code: Select all<?php
$data = array("name"=>"john", "age"=>33);
$string = http_build_query($data);
$ch = curl_init("http://192.168.2.102/");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
?>

the PHP file itself is working fine, tested it. But i failed to receive or to use the POST-data on the ESP.
I Hope one of you have a good advice for me.

Also i hope i could explain my problem understandable because my engisch is not ss good. But i try to improve it. :D

@Edit: that's embarrassing. I simple forgot the // after http: :oops: now it works fine :lol: