Results 1 to 6 of 6

Thread: Form Posting and cookies

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326
    How would I go about posting a form using the POST method within my own browser.

    For instance, if I wanted to log into my web based email account thru my own program.

    Also, would using my own web browser send my cookies along with the form posting? I'd like it to send the appropriate cookies.
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326
    I used the wizard to create a web browser, and noticed this.

    Code:
    brwWebBrowser.Navigate cboAddress.Text
    Now I also noticed that one of the options is "Post Data" I think this is what I'm looking for in order to be able to post data to the web server. Can anyone tell me how to enter the data?

    For instance if the form had a username and a password and the username were "Chris H" and the password were "pass" how would I add it onto

    Code:
    brwWebBrowser.Navigate cboAddress.Text
    *If the webpage were using the GET method life would be so much easier*

  3. #3
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    292
    If you dont need the web browser you can use the Internet Transfer control to post data to the web server.
    "People who think they know everything are a great annoyance to those of us who do."

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326
    sweet, the web browser was just a throw in.

    what is the code for the inet control to do that?

    Can I find the info at MSDN?

  5. #5
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    292
    This article says its about POST but its really about get.
    http://www.vbsquare.com/internet/cgi/

    I can try whipping up a sample POST program for you but its gonna have to wait until after my chemistry is done
    "People who think they know everything are a great annoyance to those of us who do."

  6. #6
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    292
    Ok the Internet Transfer control doesnt seem to cut it, but we can emulate a post using the Winsock control. I hacked the following little bit of code together just now so sorry if its a bit rough (its late).
    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Winsock1.Connect "sajendra.dhs.org", 80
    
    End Sub
    
    Private Sub Winsock1_Connect()
        Winsock1.SendData "GET /saj/classes/xml/CGIPost/test.asp HTTP/1.0" & vbNewLine
        Winsock1.SendData "Content-type: application/x-www-form-urlencoded" & vbNewLine
    
        
        Dim myData As String
        myData = "name=myname&password=mypassword"
        
        Winsock1.SendData "Content-length: " & Len(myData)
        Winsock1.SendData vbNewLine
        Winsock1.SendData myData
        Winsock1.SendData vbNewLine
        Winsock1.SendData vbNewLine
    
    End Sub
    
    
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
        If bytesTotal = 0 Then Exit Sub
        Dim received As String
        Winsock1.GetData received, 0, bytesTotal
        
        MsgBox received
    End Sub
    "People who think they know everything are a great annoyance to those of us who do."

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