IWebBrowser2 Navigate: Postdata not submitted

Hello everyone,

I'd like a specific webpage to be called in IE while submitting some POST data. I'm using the IWebBrowser2 interface and the navigate method. The IE is started, the page called correctly - but there is no postdata submitted (the $_POST-Array on the PHP-Server is empty). Does somebody know why?

The relevant parts in the main method:
1
2
3
4
5
6
7
8
9
10
11
12
    BSTR bstrURL2;
    bstrURL2 = SysAllocString(L"http://www.mypage.com/");
	
	
// Specify a binary Content-Type.
    V_BSTR(&vHeaders) = SysAllocString(
    L"Content-Type: application/x-www-form-urlencoded\r\n" 
    L"Content-Encoding: UTF-8\r\n");
	
    VARIANT vPostData = {0};
    if (Navigate::GetPostData(&vPostData) == NOERROR)
    r->Navigate(bstrURL2, &vFlags, &vEmpty, &vPostData, &vHeaders);


The GetPostData-method:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
HRESULT Navigate::GetPostData(LPVARIANT pvPostData)
{
	HRESULT hr;
	LPSAFEARRAY psa;
	LPCTSTR cszPostData = "username=myusername&password=mypassword";
	UINT cElems;
	LPSTR pPostData;

	cElems = lstrlen(cszPostData);

	if (!pvPostData)
	{
		return E_POINTER;
	}

	VariantInit(pvPostData);

	psa = SafeArrayCreateVector(VT_UI1, 0, cElems);
	if (!psa)
	{
		return E_OUTOFMEMORY;
	}

	hr = SafeArrayAccessData(psa, (LPVOID*)&pPostData);
	memcpy(pPostData, cszPostData, cElems);
	hr = SafeArrayUnaccessData(psa);

	V_VT(pvPostData) = VT_ARRAY | VT_UI1;
	V_ARRAY(pvPostData) = psa;
	return NOERROR;
}
Topic archived. No new replies allowed.