| Dart Home | PowerTCP Web for ActiveX | Custom Development | Reply | PowerTCP Web for ActiveX Topics | Forums |
| Author | Forum: PowerTCP Web for ActiveX Topic: POST problem |
| User81 From: Chicago, IL USA Posts: 26 Member Since: 04/03/01 |
posted March 29, 2002 7:05 PM From the web page: http://www.israelnationalnews.com/email.php3?what=report&id=642 I do a POST method as follows: http1.post "what=report&id=642&fto=phil@philmore.net&ffromname=phil&ffrom=phil@philmore.net&message=test" , , Data The page is supposed to submit an email request, but it only comes up with the same form again, indicating that the data was not properly posted. Does anyone know what I might be doing wrong? -Phil Scopes |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted March 29, 2002 7:31 PM There is probably something you need to add to the header, like a "Referer: " line. The only way that I have been able to figure stuff like this out is by using a sniffer to spy on an IE session. Then I can see exactly what IE sent in it's request. Hope this helps! Tony Priest Dart Tech Support |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted March 29, 2002 8:35 PM Actually, I just figured out how to do this using another of our products, the WebServer Tool. Here's what I did: 1) I started our WebServer sample 2) In the root directory I put a copy of the page you were requesting after removing the images and stuff. Make sure you give the file the same name as it originally had. If the action for the form has a full url, you need to change it to a local one. In this case I just called it test.htm 3) When you request the page with IE, the POST event will fire and you can extract the raw data that IE sent. From that I was able to determine that this is what you need to do. I tested it and it works: Private Sub Command1_Click() On Error GoTo OnError Command1.Enabled = False Http1.Timeout = 30000 Dim Header As New DartStrings Header.Add "Referer: http://www.israelnationalnews.com/email.php3" Dim Data As String Data = "what=report&id=642&fto=phil@philmore.net&ffromname=phil&ffrom=phil@philmore.net&message=test!&submit=send" Http1.Url = "http://www.israelnationalnews.com/email.php3" Http1.Post Data, Header GoTo Done OnError: Debug.Print "ERROR #" + CStr(Err.Number) + ": " + Err.Description Done: Command1.Enabled = True End Sub Hope this helps! Tony Priest Dart Tech Support |
| User81 From: Chicago, IL USA Posts: 26 Member Since: 04/03/01 |
posted March 29, 2002 9:15 PM Thank you for getting back to me. I tried to run your code as entered. The page that comes back has the form on it, and it should not -- it should just have a message that says that the email has been sent. |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted March 29, 2002 11:09 PM Are you sure? I modified the code to write out the response. The response contained the following message: "Message was successfully sent" and I received the report via email. I just ran the following code, which should have caused a report to have been sent to you: Private Sub Command1_Click() On Error GoTo OnError Command1.Enabled = False Http1.Timeout = 30000 Dim Header As New DartStrings Header.Add "Referer: http://www.israelnationalnews.com/email.php3" Dim Data As String Data = "what=report&id=642&fto=phil@philmore.net&ffromname=Tony Priest&ffrom=blah@blah.com&message=Test from Tony!&submit=send" Http1.Url = "http://www.israelnationalnews.com/email.php3" Dim Response As String Http1.Post Data, Header, Response Dim Stream As New DartStream Stream.FileMode = createAlways Stream.FileName = "response.htm" Stream.Write Response GoTo Done OnError: Debug.Print "ERROR #" + CStr(Err.Number) + ": " + Err.Description Done: Command1.Enabled = True End Sub |
| User81 From: Chicago, IL USA Posts: 26 Member Since: 04/03/01 |
posted April 3, 2002 5:49 PM I got my project working. The problem was that I needed to send the Data string in unencoded form. Since the site I was using accepts email addresses and other text, with @ symbols and spaces included, my program was encoding substituting the ASCII codes, as in %20 for a space or %40 for the @ sign. This is appropriate for a GET, but not for a POST. |
| Reply | PowerTCP Web for ActiveX Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|