|
-
May 20th, 2010, 12:08 AM
#1
Thread Starter
Fanatic Member
Winsock POST Problem GET WORKS
Hi
i have this code and it works when the method is selected as GET but does not work when i select the POST method. What is wrong please help
Code:
Private Sub Winsock1_Connect()
Dim Url As String
Dim StrTh As String
StrTh = "POST " & "http://localhost/winsock/winsock/post.php?name=" & Text1.Text & "&email=" & Text2.Text & "&msg=" & Text3.Text & vbCrLf
StrTh = StrTh & "HTTP/1.0" & vbCrLf
StrTh = StrTh & "Accept: */*" & vbCrLf
StrTh = StrTh & "Accept: text/html" & vbCrLf & vbCrLf
StrTh = StrTh & "Content-Type: application/x-www-form-urlencoded" & vbCrLf
Winsock1.SendData StrTh
End Sub
-
May 20th, 2010, 10:44 AM
#2
Hyperactive Member
Re: Winsock POST Problem GET WORKS
Whats running on localhost
-
May 20th, 2010, 12:45 PM
#3
Thread Starter
Fanatic Member
Re: Winsock POST Problem GET WORKS
 Originally Posted by 5ms?
Whats running on localhost
a php page
Code:
<?php
$name = $_GET['name'];
$email = $_GET['email'];
$msg = $_GET['msg'];
$lnk = mysql_connect("localhost","root","mysql");
$d = mysql_select_db("winsock");
$sql = "INSERT INTO tbl_data (name, email, msg) VALUES ('$name','$email','$msg')";
$res = mysql_query($sql);
echo "Done";
?>
-
May 20th, 2010, 02:44 PM
#4
Hyperactive Member
Re: Winsock POST Problem GET WORKS
Run this and see what you get.
Code:
<?php
$name = $_GET['name'];
echo $name;
?>
-
May 20th, 2010, 04:53 PM
#5
Frenzied Member
Re: Winsock POST Problem GET WORKS
Code:
Private Sub Winsock1_Connect()
Dim Url As String
Dim StrTh As String
StrTh = "GET /winsock/winsock/post.php?name=" & Text1.Text & "&email=" & Text2.Text & "&msg=" & Text3.Text & vbCrLf
StrTh = StrTh & "Host: localhost" & vbnewline'dunno
StrTh = StrTh & "HTTP/1.0" & vbCrLf
StrTh = StrTh & "Accept: */*" & vbCrLf
StrTh = StrTh & "Accept: text/html" & vbCrLf & vbCrLf
StrTh = StrTh & "Content-Type: application/x-www-form-urlencoded" & vbCrLf
Winsock1.SendData StrTh
End Sub
-
May 20th, 2010, 07:32 PM
#6
Hyperactive Member
Re: Winsock POST Problem GET WORKS
 Originally Posted by chunk
Hi
i have this code and it works when the method is selected as GET but does not work when i select the POST method. What is wrong please help
Code:
Private Sub Winsock1_Connect()
Dim Url As String
Dim StrTh As String
StrTh = "POST " & "http://localhost/winsock/winsock/post.php?name=" & Text1.Text & "&email=" & Text2.Text & "&msg=" & Text3.Text & vbCrLf
StrTh = StrTh & "HTTP/1.0" & vbCrLf
StrTh = StrTh & "Accept: */*" & vbCrLf
StrTh = StrTh & "Accept: text/html" & vbCrLf & vbCrLf
StrTh = StrTh & "Content-Type: application/x-www-form-urlencoded" & vbCrLf
Winsock1.SendData StrTh
End Sub
May be
Code:
if($_SERVER['REQUEST_METHOD'] == "POST")
-
May 20th, 2010, 08:21 PM
#7
Frenzied Member
Re: Winsock POST Problem GET WORKS
You're POSTing, but there's no Content-Length or data being sent.
Use GET
-
May 20th, 2010, 10:12 PM
#8
Re: Winsock POST Problem GET WORKS
Uhm.... Your HTTP header seems a bit awkward. I don't know how important it is, but usually HTTP/1.0 is not on a new line, but is after the URL, with a space between them.
And usually the only field with a double newline is the final field before the actual content. Plus you have two Accept fields, and no Accept-language, or content-length. So you're not posting content....
Indeed, try GET.
Software I use and highly recommend: Opera, Miranda IM, Peerblock, Winamp, Unlocker Assistant, JoyToKey, Virtual CloneDrive, Secunia PSI, ExplorerXP, GOM Player, Real Alternative, Quicktime Alternative,Sumatra PDF, and non-freeware: Photoshop and VB6( ).
My codebank: AllRGB, Rounded Rectangle(math), Binary Server, Buddy Paint, LoadPictureGDI+, System GUID/Volume Serial, HexToAsc, List all processes and their paths, quasiString matching
Strings(search, extraction, retrieval etc): Retrieve BBCode Link from HTML, RemoveBetween ()'s, strFindBetween(str1,str2), Insert text in HTML, HTML - GetSpanByID
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|