GnatMan
asked on
Please help a newbie
Hi guys, Newbie here,
I am using Visual Basic 6.0(SP3) and am using the inet.execute "POST" function to send some name=value pair variables to a VB CGI script. I didn't write the CGI script but this is what it looks like to get the input
************************** ********** ********** ******
Public Function CGIStdIn() As String
Dim lngStdInput As Long ' Handle of Standard Input
Dim strStdInput As String ' String of Standard Input
Dim lngNumberOfBytesToRead As Long ' Number of bytes in standard input
Dim lngNumberOfBytesRead As Long ' Number of bytes read in standard input
Dim typOverlapped As OVERLAPPED ' Structure used in ReadFile() function call
Dim lngResult As Long ' Did Standard Input Work?
On Error Resume Next
lngStdInput = GetStdHandle(STD_INPUT_HAN DLE) ' Get standard input handle
CGIStdIn = ""
If lngStdInput > -1 Then ' If a valid handle was found
' Find out how big the input stream is
lngNumberOfBytesToRead = CLng(Environ("CONTENT_LENG TH"))
' Initialize string variable to store the standard input stream
strStdInput = String(lngNumberOfBytesToR ead, " ")
lngResult = ReadFile(lngStdInput, strStdInput, lngNumberOfBytesToRead, _
lngNumberOfBytesRead, typOverlapped)
strStdInput = RTrim(strStdInput) ' Get rid of any trailing spaces
CGIStdIn = strStdInput ' Return standard input stream
End If
If CGIStdIn <> "" Then
' Add the tail of the string if <CR> was hit instead of the login button
If Right(CGIStdIn, 1) <> "&" Then
CGIStdIn = CGIStdIn & "&Login_Submit=Login"
End If
End If
End Function
************************** ********** *****
Now here's the problem, it works fine when you push the login button from the browser, but when I try to use my VB application to post info to the script, all I get is a No response timeout. Can anyone help me with a reason why the VB CGI script does not like this POST?
I'm pretty sure my code should work, all indications from examples suggest it should.
Private Sub cmdPOST_Click()
picTic.Visible = True
txtData.Text = ""
Dim fnum As Integer
Dim file_name As String
Dim got_file As Boolean
Dim txt As String
' Get the file's name.
file_name = App.Path
If Right$(file_name, 1) <> "\" Then file_name = file_name & "\"
file_name = file_name & "logins.txt"
' Open the file.
fnum = FreeFile
On Error Resume Next
Open file_name For Input As fnum
got_file = (Err.Number = 0)
On Error GoTo 0
If got_file Then
' Read the text.
Do Until EOF(fnum)
Dim i As Integer
Dim sArray As Variant
Input #fnum, txt
sArray = Split(txt)
txtRemotePath.Text = "MNO=" & sArray(0) & "&PWD=" & sArray(1) _
& "&BSB=NTV25"
Loop
' Close the file.
Close fnum
End If
Inet1.Execute txtURL.Text, "POST", txtRemotePath.Text, _
"enctype: application/x-www-form-url encoded"
Exit Sub
End Sub
Thanks in advance
nathan
I am using Visual Basic 6.0(SP3) and am using the inet.execute "POST" function to send some name=value pair variables to a VB CGI script. I didn't write the CGI script but this is what it looks like to get the input
**************************
Public Function CGIStdIn() As String
Dim lngStdInput As Long ' Handle of Standard Input
Dim strStdInput As String ' String of Standard Input
Dim lngNumberOfBytesToRead As Long ' Number of bytes in standard input
Dim lngNumberOfBytesRead As Long ' Number of bytes read in standard input
Dim typOverlapped As OVERLAPPED ' Structure used in ReadFile() function call
Dim lngResult As Long ' Did Standard Input Work?
On Error Resume Next
lngStdInput = GetStdHandle(STD_INPUT_HAN
CGIStdIn = ""
If lngStdInput > -1 Then ' If a valid handle was found
' Find out how big the input stream is
lngNumberOfBytesToRead = CLng(Environ("CONTENT_LENG
' Initialize string variable to store the standard input stream
strStdInput = String(lngNumberOfBytesToR
lngResult = ReadFile(lngStdInput, strStdInput, lngNumberOfBytesToRead, _
lngNumberOfBytesRead, typOverlapped)
strStdInput = RTrim(strStdInput) ' Get rid of any trailing spaces
CGIStdIn = strStdInput ' Return standard input stream
End If
If CGIStdIn <> "" Then
' Add the tail of the string if <CR> was hit instead of the login button
If Right(CGIStdIn, 1) <> "&" Then
CGIStdIn = CGIStdIn & "&Login_Submit=Login"
End If
End If
End Function
**************************
Now here's the problem, it works fine when you push the login button from the browser, but when I try to use my VB application to post info to the script, all I get is a No response timeout. Can anyone help me with a reason why the VB CGI script does not like this POST?
I'm pretty sure my code should work, all indications from examples suggest it should.
Private Sub cmdPOST_Click()
picTic.Visible = True
txtData.Text = ""
Dim fnum As Integer
Dim file_name As String
Dim got_file As Boolean
Dim txt As String
' Get the file's name.
file_name = App.Path
If Right$(file_name, 1) <> "\" Then file_name = file_name & "\"
file_name = file_name & "logins.txt"
' Open the file.
fnum = FreeFile
On Error Resume Next
Open file_name For Input As fnum
got_file = (Err.Number = 0)
On Error GoTo 0
If got_file Then
' Read the text.
Do Until EOF(fnum)
Dim i As Integer
Dim sArray As Variant
Input #fnum, txt
sArray = Split(txt)
txtRemotePath.Text = "MNO=" & sArray(0) & "&PWD=" & sArray(1) _
& "&BSB=NTV25"
Loop
' Close the file.
Close fnum
End If
Inet1.Execute txtURL.Text, "POST", txtRemotePath.Text, _
"enctype: application/x-www-form-url
Exit Sub
End Sub
Thanks in advance
nathan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Does the site work if you type in the POST directly into the address bar of your Browser?
e.g.
http://www.foo.com/foo?a=b&c=d
e.g.
http://www.foo.com/foo?a=b&c=d
ASKER
I've tried that, it doesn't work either, that's using the GET method though isn't it? Isn't the CGI VB script grabbing the info from STDinput from POSTed data?
Thanks
Thanks
ASKER