Solved

Intet Control HTTP POST

Posted on 2002-06-03
5
303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 52

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

729 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