No results during Post HttpRequest

Back to topics list To post a new topic, please log in or register
avatar
5
sky90 2016.08.05 01:58
 

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 = "";
   while(InternetReadFile(HttpRequest,ch,500,dwBytes))
   {
      if(dwBytes<=0) break;
      toStr=toStr+CharArrayToString(ch,0,dwBytes);
   }
   
   strWebPage=toStr; 
   
   
   
   InternetCloseHandle(HttpOpen);
   InternetCloseHandle(HttpRequest);
   
   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
#import "kernel32.dll"
int GetLastError(void);
#import

 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. 

Back to topics list  

To add comments, please log in or register