Results 1 to 13 of 13

Thread: Executing PHP Script from VB6 *RESOLVED*

Threaded View

  1. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Executing PHP Script from VB6

    The problem is in your HTTP request. I recognise it from the reply I gave Electroman earlier. Let me explain it a little more.
    • \r\n is the PHP escape sequence for the carridge return and new line characters. Each header in the HTTP request must be seaparted by a CRLF line ending. As VB does not understand \r\n you need to use the vbCrLF constant. To signify the end of the headers and the start of the content we use a blank line.
    • The Content-Length header must be the exact number of characters in your message body. In this case you've used 65, which is incroeect.
    • The third problem, is you have told the server you will be using URL encoding in the message body but the data is not encoded properly. Namely the space hasn't been converted to %20 or a + chracter.

    This corrected version should work:
    VB Code:
    1. Private Sub Winsock1_Connect()
    2.     Dim strHttpRequest As String
    3.     Dim strPHP As String
    4.     Dim strData As String
    5.     Dim intContentLength As Integer
    6.  
    7.     strData = "Var1=Jesse&Var2=21&Var3=Fort+Collins"
    8.     intContentLength = Len(strData)
    9.    
    10.     strPHP = Text4 & "/vbMail.php"
    11.     strHttpRequest = "POST " & strPHP & " HTTP/1.0" & vbCrLf & _
    12.                      " Content-Length:" & intContentLength & vbCrLf  & _
    13.                      " Content-Type: application/x-www-from-urlencoded" & vbCrLf & _
    14.                      vbCrLf & strData
    15.    
    16.  Winsock1.SendData strHttpRequest
    17. End Sub
    Last edited by visualAd; Feb 21st, 2005 at 01:51 PM.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width