POST operation - how to?

POST operation - how to?

Post by Oz » Thu, 07 Mar 2002 07:53:45



Can anyone please explain how I use the POST operation in the EXECUTE method
for HTTP transfer?

I'm searching a web page by submitting zip codes and using the returned data
for later formatting.

I've included the relevant part of the web page source and below that I have
the way I think I should be posting the data using the inet control. I'm a
novice to VB so apologies in advance for any glaringly obvious mistakes, but
the simple fact is that I just don't know.

Hope someone can show me the errors of my ways!

Cheers

Oz
Example HTML:

<FORM ACTION="radial.search" METHOD="post" name = "radial">
<hr>
<p>Please enter the A-End and B-End information for the calculation.
<table><tr><th><th bgcolor = "black"><font color = "white">A-End</font><th
bgcolor = "black"><font color = "white">B-End</font><tr>
<th bgcolor = "black">
<font color = "white">
Search Type:</font>
<th>
&nbsp;<SELECT NAME="SearchTypeA" SIZE="1">
    <option value = a> Place Codes </option>
    <option value = b> Telephone Numbers </option>
    <option value = c> Exchange Names </option>
    <option selected value = d> Postcode </option>
</SELECT>
</th><BR>
<th>
&nbsp;<SELECT NAME="SearchTypeB" SIZE="1">
    <option value = a> Place Codes </option>
    <option value = b> Telephone Numbers </option>
    <option value = c> Exchange Names </option>
    <option selected value = d> Postcode </option>
</SELECT>
</th><BR>
  <tr><th bgcolor = "black"><font color = "white">Search Data:</font><th>
<input type = "text" name = "a" size = "20" maxlength = "20">
<th>
<input type = "text" name = "b" size = "20" maxlength = "20">
<input type = "hidden" name = "help" value = "">
</TABLE>
<input type = "submit" value = "Submit">
<input type = "reset" value = "Reset">
</p></form>
<hr>

</b>
</BODY>
</HTML>

Example Code:

Private Sub cmdStart_Click()

Dim b() As Byte
Dim intCount As Integer
Dim strData As String
Dim strURL As String
Dim strFormData As String
Dim strFormData1 As String

Inet1.Cancel ' Stops any current operations

strURL = "http://www.myurl.com:8080/my.search"
strFormData = "a=90210&b=90210"

Inet1.Execute strURL, "POST", strFormData

end sub

Private Sub Inet1_StateChanged(ByVal State As Integer)

Dim vtData As Variant ' Data variable.
    Select Case State
    ' ... Other cases not shown.
    Case icResponseCompleted ' 12
        ' Open a file to write to.
        Open "webdata.txt" For Binary Access Write As #1

        ' Get the first chunk. NOTE: specify a Byte
        ' array (icByteArray) to retrieve a binary file.
        vtData = Inet1.GetChunk(1024, icString)

        Do While LenB(vtData) > 0
            Put #1, , vtData
            ' Get next chunk.
            vtData = Inet1.GetChunk(1024, icString)
        Loop
        Put #1, , vtData
        Close #1
End Select
End Sub