Solved

Intet Control HTTP POST

Posted on 2002-06-03
5
301 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 51

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
to transfer string from C lanaguage to VBA 4 77
Add and format columns in vb6 7 71
Dinamic report to Crosstab query 9 52
Set WorkSheet  not Working 9 52
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

733 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