C
corporateattitude
Hello.
I have a question concerning how to post a form to a webpage in VB
6.0. The following is my webpage. I've already design a function to
collect the following data: desire1, desire2, description, accesskey,
process_on and identity. Have I collected the right data? I've saved
all in a string in this way:
desire1="my first desire"&desire2="my second desire"&description="my
description"&accesskey="v"&process_on="2007-08-23
08:58:57"&identity="1001"
How to post this string?
Source code of my form:
<html>
<body>
<form action="index-text.php?locale=2" method="post" id="validation">
<div id="root" class="txt">
Internaute :
</div>
<ul class="gouts">
<li><strong>Aime :</strong></li>
<li><input type="text" name="desire1" size="48" value="" /></
li>
<li><input type="text" name="desire2" size="48" value="" /></
li>
</ul>
<br class="clear" />
<div class="presentation">
<p><strong>Présentation :</strong><br />
<textarea name="description">Description of websurfer</
textarea>
</p>
</div>
<p>
<input type="submit" name="action" value="Erase" class="delete"
accesskey="d" />
<input type="submit" name="action" value="Submit" accesskey="v"/>
<input type="hidden" name="process_on" value="2007-08-23
08:58:57" />
<input type="hidden" name="identity" value="1001" />
</p>
</form>
</body>
</html>
I've got a source code form Dave Hansens ([email protected]) but I
don't know how to use it. Please help me.
Dim post_response as String
Dim in_sending as Boolean
Dim total_buf as String
Dim SendResults as String
Dim rec_buf as String
Dim received_response as Boolean
Private Sub send_post_data(TextData as string)
Dim strURL As String
Dim postdata As String
Dim Headers As String
On Error GoTo 0
strURL = "https://www.thewebserver.com/savedata.asp"
received_response = False
postdata = "x=x&user=dave&pass=GoYahoo&age=youngenough&year=" &
strYear & "&id=" & ID & _
"&TextData=" & sURLencoded(TextData) & _
"&submit=Save" '& vbCrLf
Headers = "Accept: */*" & vbCrLf & _
"Referer: https://www.thewebserver.com/forms/dataform.htm" & vbCrLf &
_
"Pragma: no-cache" & vbCrLf & _
"Accept-Language: en-us" & vbCrLf & _
"Content-Length: " & Len(postdata) & vbCrLf & _
"Content-Type: application/x-www-form-urlencoded" & vbCrLf
post_response = ""
is_sending = True
Call Inet1.Execute(strURL, "POST", postdata, Headers)
While (Inet1.StillExecuting)
DoEvents
If post_response <> "" Then GoTo done
Wend
done:
SendResults = post_response
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim bDone As Boolean
If State = 12 Then
bDone = False
' Get first chunk.
rec_buf = Inet1.GetChunk(1024, icString)
DoEvents
Do While Not bDone
total_buf = total_buf & rec_buf
DoEvents
rec_buf = Inet1.GetChunk(1024, icString)
If Len(rec_buf) = 0 Then
bDone = True
received_response = True
If is_sending Then
post_response = total_buf
total_buf = ""
End If
Exit Sub
End If
Loop
End If
End Sub
Public Function sURLencoded(istr As String) As String
Dim rc As String
Dim fd As Integer
Dim fsize As Long
Dim i As Long
Dim ch As String
Dim a As Integer
rc = ""
fsize = Len(istr)
For i = 1 To fsize:
ch = Mid$(istr, i, 1)
a = Asc(ch)
If a < 32 Or a > 122 Then
ch = "%" & Hex(a)
Else
If ch = " " Then
ch = "+"
Else
End If
End If
End If
rc = rc & ch
Next i
sURLencoded = rc
End Function
I'm desperate, please help me.
I have a question concerning how to post a form to a webpage in VB
6.0. The following is my webpage. I've already design a function to
collect the following data: desire1, desire2, description, accesskey,
process_on and identity. Have I collected the right data? I've saved
all in a string in this way:
desire1="my first desire"&desire2="my second desire"&description="my
description"&accesskey="v"&process_on="2007-08-23
08:58:57"&identity="1001"
How to post this string?
Source code of my form:
<html>
<body>
<form action="index-text.php?locale=2" method="post" id="validation">
<div id="root" class="txt">
Internaute :
</div>
<ul class="gouts">
<li><strong>Aime :</strong></li>
<li><input type="text" name="desire1" size="48" value="" /></
li>
<li><input type="text" name="desire2" size="48" value="" /></
li>
</ul>
<br class="clear" />
<div class="presentation">
<p><strong>Présentation :</strong><br />
<textarea name="description">Description of websurfer</
textarea>
</p>
</div>
<p>
<input type="submit" name="action" value="Erase" class="delete"
accesskey="d" />
<input type="submit" name="action" value="Submit" accesskey="v"/>
<input type="hidden" name="process_on" value="2007-08-23
08:58:57" />
<input type="hidden" name="identity" value="1001" />
</p>
</form>
</body>
</html>
I've got a source code form Dave Hansens ([email protected]) but I
don't know how to use it. Please help me.
Dim post_response as String
Dim in_sending as Boolean
Dim total_buf as String
Dim SendResults as String
Dim rec_buf as String
Dim received_response as Boolean
Private Sub send_post_data(TextData as string)
Dim strURL As String
Dim postdata As String
Dim Headers As String
On Error GoTo 0
strURL = "https://www.thewebserver.com/savedata.asp"
received_response = False
postdata = "x=x&user=dave&pass=GoYahoo&age=youngenough&year=" &
strYear & "&id=" & ID & _
"&TextData=" & sURLencoded(TextData) & _
"&submit=Save" '& vbCrLf
Headers = "Accept: */*" & vbCrLf & _
"Referer: https://www.thewebserver.com/forms/dataform.htm" & vbCrLf &
_
"Pragma: no-cache" & vbCrLf & _
"Accept-Language: en-us" & vbCrLf & _
"Content-Length: " & Len(postdata) & vbCrLf & _
"Content-Type: application/x-www-form-urlencoded" & vbCrLf
post_response = ""
is_sending = True
Call Inet1.Execute(strURL, "POST", postdata, Headers)
While (Inet1.StillExecuting)
DoEvents
If post_response <> "" Then GoTo done
Wend
done:
SendResults = post_response
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim bDone As Boolean
If State = 12 Then
bDone = False
' Get first chunk.
rec_buf = Inet1.GetChunk(1024, icString)
DoEvents
Do While Not bDone
total_buf = total_buf & rec_buf
DoEvents
rec_buf = Inet1.GetChunk(1024, icString)
If Len(rec_buf) = 0 Then
bDone = True
received_response = True
If is_sending Then
post_response = total_buf
total_buf = ""
End If
Exit Sub
End If
Loop
End If
End Sub
Public Function sURLencoded(istr As String) As String
Dim rc As String
Dim fd As Integer
Dim fsize As Long
Dim i As Long
Dim ch As String
Dim a As Integer
rc = ""
fsize = Len(istr)
For i = 1 To fsize:
ch = Mid$(istr, i, 1)
a = Asc(ch)
If a < 32 Or a > 122 Then
ch = "%" & Hex(a)
Else
If ch = " " Then
ch = "+"
Else
ch = "%" & Hex(a)If (a > 33 And a said:= 91 And a <= 96) Then
End If
End If
End If
rc = rc & ch
Next i
sURLencoded = rc
End Function
I'm desperate, please help me.