Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server is not receving posted data using HTTP API (HttpSendRequest wit

Status
Not open for further replies.

dhamukrish

Programmer
Mar 5, 2001
1
AU
Hello,
I am writing an application to pass data to html hidden fields. I wrote a code similar to your sample code given in
in KB articles(Q175474).

API Code:
-----------------------------------------------------
Dim hInternetOpen As Long
Dim hInternetConnect As Long
Dim hHttpOpenRequest As Long
Dim bRet As Boolean

hInternetOpen = 0
hInternetConnect = 0
hHttpOpenRequest = 0

'Use registry access settings.
Const INTERNET_OPEN_TYPE_PRECONFIG = 0
hInternetOpen = InternetOpen("http generic", _
INTERNET_OPEN_TYPE_PRECONFIG, _
vbNullString, _
vbNullString, 0)

If hInternetOpen <> 0 Then
'Type of service to access.
Const INTERNET_SERVICE_HTTP = 3
Const INTERNET_DEFAULT_HTTP_PORT = 80

'Change the server to your server name
hInternetConnect = InternetConnect(hInternetOpen, _
&quot;csplhsvr&quot;, _
INTERNET_DEFAULT_HTTP_PORT, _
vbNullString, _
&quot;HTTP/1.0&quot;, _
INTERNET_SERVICE_HTTP, _
0, 0)

If hInternetConnect <> 0 Then
'Brings the data across the wire even if it locally cached.
Const INTERNET_FLAG_RELOAD = &H80000000

'?fname=Prabha&lname=Dhamodharan&quot;
hHttpOpenRequest = HttpOpenRequest(hInternetConnect, _
&quot;GET&quot;, _
&quot;/HTTPTest/ReadPost.asp&quot;, _
&quot;HTTP/1.1&quot;, _
vbNullString, _
0, INTERNET_FLAG_RELOAD, 0)

If hHttpOpenRequest <> 0 Then
Dim sHeader As String

Const HTTP_ADDREQ_FLAG_ADD = &H20000000
Const HTTP_ADDREQ_FLAG_REPLACE = &H80000000

sHeader = &quot;Content-Type: application/x- & vbCrLf
bRet = HttpAddRequestHeaders(hHttpOpenRequest, _
sHeader, Len(sHeader), _
HTTP_ADDREQ_FLAG_REPLACE Or _
HTTP_ADDREQ_FLAG_ADD)

Dim lpszPostData As String
lpszPostData = &quot;fname=Prabha&lname=Dhamodharan&quot;

bRet = HttpSendRequest(hHttpOpenRequest, _
vbNullString, 0, _
lpszPostData, Len(lpszPostData))

Dim bDoLoop As Boolean
Dim sReadBuffer As String * 2048
Dim lNumberOfBytesRead As Long
Dim sBuffer As String

bDoLoop = True
While bDoLoop
sReadBuffer = vbNullString
bDoLoop = InternetReadFile(hHttpOpenRequest, _
sReadBuffer, Len(sReadBuffer), lNumberOfBytesRead)
sBuffer = sBuffer & Left(sReadBuffer, lNumberOfBytesRead)

If Not CBool(lNumberOfBytesRead) Then bDoLoop = False
Wend

MsgBox sBuffer
bRet = InternetCloseHandle(hHttpOpenRequest)

End If
bRet = InternetCloseHandle(hInternetConnect)

End If
bRet = InternetCloseHandle(hInternetOpen)

End If
------------------------------------------------------

From the above code, 'fname' and 'lname' are transferred to server for display as per the code given, but 'txtData' is not displayed

Server side asp code
-----------------------------------------------------
fname : <%=Request(&quot;fname&quot;)%>
lname : <%=Request(&quot;lname&quot;)%>
-----------------------------------------------------

I received only
-----------------------------------------------------
fname :
lname :
-----------------------------------------------------

Please advise us.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top