Solved

Intet Control HTTP POST

Posted on 2002-06-03
5
296 Views
Last Modified: 2010-05-02
Can someone give me some code to http POST to a PHP script? Using VB6

I can get examples to work using the OpenURL method but not the Execute Post method.

Regards,
John
0
Comment
Question by:MAVERICK
5 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 7050553
Try using WebBrowser Control?
0
 
LVL 1

Author Comment

by:MAVERICK
ID: 7050650
I dont need a web browser.. just the POST & Response

Regards,
John

0
 
LVL 38

Accepted Solution

by:
PaulHews earned 100 total points
ID: 7051313
Here's a sample that posts data to a cgi.

Private Sub Command1_Click()

       Dim strURL As String, strFormData As String
       
       
       strURL = "http://custos.earthlink.net/cgi/popbrowse.cgi"
       strFormData = "Area=" & Text2 & "&State=CA&Country=1&Service=V.34%2CV.90%2CK56%2CX2%2CISDN1%2CISDN2&Button=Find+Numbers"
       Inet1.Execute strURL, "Post", strFormData, "Content-Type: application/x-www-form-urlencoded"
         
       

End Sub

Private Sub Form_Load()
   Text2 = ""
   
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
  Dim vtData As Variant
  Dim strData As String
  Dim hFile As Integer
       
  Select Case State
     Case icError
        ' An error has occurhFiled.
        MsgBox (Inet1.ResponseCode & ":" & Inet1.ResponseInfo)
        Inet1.Cancel
     Case icResponseCompleted
        strData = ""
        ' Loop: get chunks of the hFilesponse
        Do
           DoEvents
           vtData = Inet1.GetChunk(1024, icString)
           strData = strData & vtData
        Loop Until Len(vtData) = 0
        Call sProcess(strData)
        ' Save the hFilesponse to "hFileturn.htm" in the default dihFilectory
        hFile = FreeFile
        Open App.Path & "\Response.htm" For Output As #hFile
        Print #hFile, strData
        Close (hFile)
       
        ' Open "Response.htm" with the default browser
        Call ShellExecute(Me.hwnd, vbNullString, App.Path & "\Response.htm", vbNullString, vbNullString,
SW_SHOWNORMAL)
       
  End Select
End Sub

Public Sub sProcess(strData As String)
   Const Head = "<html><head><title>Earthlink numbers</title></head><body bgcolor='#73BDE6'>" & vbCrLf
   Const Tail = "</body></html>"
   '<TABLE CELLSPACING="1" BORDER="1" CELLPADDING="0">
   Const Table = "<TABLE CELLSPACING=""1"" BORDER=""1"" CELLPADDING=""0"">"
   Dim lngPosH As Long, lngPosT As Long
   
   lngPosH = InStr(1, strData, Table, vbTextCompare) + Len(Table)
   lngPosT = InStr(1, strData, "</TABLE>", vbTextCompare)

   strData = Head & Table & Mid$(strData, lngPosH, lngPosT - lngPosH) & "<?TABLE>" & Tail
   

End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7054327
interesting...
0
 
LVL 1

Author Comment

by:MAVERICK
ID: 7083783
I tried out the example.. and it worked as expected & Solved the problem

Thanks
Maverick
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now