Download MetaTrader 5

No results during Post HttpRequest

To add comments, please log in or register

Hi, I don't receive results when I do a Post Http Request,  instead with a Get Http Request this code works:


string GetPHP(string path, string data)
   string headers = "Content-Type: application/x-www-form-urlencoded";
   string Types = "";
   char acceptTypes[];
   StringToCharArray(Types, acceptTypes);
   int HttpOpen = InternetOpenW(" ", 0, " ", "", 0);  
   int HttpConnect = InternetConnectW(HttpOpen, PHP_URL, 80, "", "", 3, 0, 0);
   int HttpRequest = HttpOpenRequestW(HttpConnect, "POST", path, "", "", acceptTypes, 0, 0);   
   bool result = HttpSendRequestW(HttpRequest, headers, StringLen(headers), data, StringLen(data));
   Alert ("Last MSDN Error =: ", kernel32::GetLastError());
   int read[1];
   Print("This is the POST result: ", result);

   uchar ch[500];
   string toStr="";
   int dwBytes;
   string strWebPage = "";
      if(dwBytes<=0) break;
   return strWebPage;

 These are imported functions:

#import  "Wininet.dll"
   int InternetOpenW(string, int, string, string, int);
   int InternetConnectW(int, string, int, string, string, int, int, int); 
   int InternetOpenUrlW(int, string, string, int, int, int);
   int InternetReadFile(int, uchar &sBuffer[], int, int& OneInt);
   int InternetCloseHandle(int); 
   int HttpOpenRequestW(int, string, string, string, string, char& AcceptTypes[], int, int);
   bool HttpSendRequestW(int, string, int, string, int);
#import "kernel32.dll"
int GetLastError(void);

 I found this code in this forum and I would say thank you just for that!

 I put in data variable this code to do a Post request:

data = "name="+Variable+"&age="+Variable2;

Then in the php script I have 

$variable = $_POST['name'];


But no results shown. How can I fix that? Thank you for your patience and help. 

To add comments, please log in or register