Current location: Hot Scripts Forums » Programming Languages » Visual Basic » logging into website (sending form data)


logging into website (sending form data)

Reply
  #1 (permalink)  
Old 12-04-05, 12:56 AM
gnznroses gnznroses is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
logging into website (sending form data)

i'm trying to post form data to two websites and get the resulting webpage. i can get this to work on other sites, but not these two. i can't figure out why. i'm using a winsock control to do it.




basically, like this:
Code:
            Domain = "www." & tmpstring & ".com"
            Address = "/login.aspx"
            FormData = "fldEmail=" & "blah@domain.com" & "&fldPassword=" & "mypass" ' & "&action=submit" & "&PHPSESSID=" & "865a933771deaae06d3dcf5a220ce5a2"
            Winsock1.RemoteHost = Domain
            Winsock1.RemotePort = 80
            'AddStatus "connecting..."
            If Winsock1.State <> sckConnected Then Winsock1.Connect
            Do Until Winsock1.State = sckConnected
                DoEvents
            Loop
            'FormData = Replace(FormData, " ", "+")
            'FormData = Replace(FormData, vbCrLf, "%0D%0A")
            WebPage = "POST " & Address & " HTTP/1.1" & vbCrLf
            WebPage = WebPage & "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-comet, */*" & vbCrLf
            WebPage = WebPage & "Accept-Language: en-us" & vbCrLf
            WebPage = WebPage & "Referer: " & Domain & vbCrLf
            WebPage = WebPage & "Content-Type: application/x-www-form-urlencoded" & vbCrLf
            WebPage = WebPage & "Accept-Encoding: gzip, deflate" & vbCrLf
            'WebPage = WebPage & "User-Agent: Mozilla/4.05 [en] (Win95; I)" & vbCrLf
            WebPage = WebPage & "User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 95; SPEED; DigExt)" & vbCrLf
            WebPage = WebPage & "Host: " & Winsock1.RemoteHost & vbCrLf
            'WebPage = WebPage & "Cookie: ASPSESSIONIDSQCACDBQ=KOHEMKPBAJHIFNHBAFDKBBDM; path=/"
            'WebPage = WebPage & "Cookie: PHPSESSID=85a52d030721d6d1d9597dc0c4a09585"
            'WebPage = WebPage & "Connection: Keep-Alive" & vbCrLf
            WebPage = WebPage & "Connection: Close" & vbCrLf
            WebPage = WebPage & "Content-Length: " & CStr(Len(FormData)) & vbCrLf & vbCrLf
            WebPage = WebPage & FormData & vbCrLf ' & vbCrLf
        
            'Voting = True
            blnRetVal = WinsockSend(Winsock1, WebPage)
            Do Until sndComplete = True
                DoEvents
            Loop
            sndComplete = False
            Text2.Text = m_strHttpResponse


every time tho all i get back is a page telling me to log in. when i've done this before i found that with one site i had to pass a cookie value and also set the referrer value to the site's homepage. but, using the Opera browser, and it's cookie viewer/editor, i've found that i can go directly to the log-in page, delete the cookie that's created, and log in just fine.

i'm passing all of the variables that are in the form inputs, so what else could be missing? i don't understand.

also, with another site that creates permanent cookies (don't expire til 2030 or something) i can simply use the inet control to retrieve the webpage i need (ie mysite.com/members.php). but, if i go to the two sites mentioned earlier, in IE, then try the same thing, while the session cookie still exists, and it won't work.

any help would be appreciated.
Reply With Quote
  #2 (permalink)  
Old 12-05-05, 05:32 PM
gnznroses gnznroses is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
ok, it must be a problem with how the form data is snet, cause this simple html page works just fine:

<html><body>
<FORM ACTION="http://www.3604free.com/members.php" METHOD="post">
<INPUT TYPE="hidden" NAME="action" VALUE="submit">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit" value="Submit" name="B1">
<input type="checkbox" name="chekor" value="ON" checked></form>
</body></html>
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP upload prob minority ASP 1 06-27-05 08:35 AM
Sending data from form to VBscript sub_focus ASP 1 03-18-05 03:28 PM
FS: Prozilla Memberships (Turnkey Sites) - $10-15 less than Retail! rockergrrl General Advertisements 0 08-11-04 12:05 AM
Sending form data + attatchments in email php-learner PHP 2 02-14-04 12:18 AM
Collecting html form data and sending it to a sql table crobinson ASP 3 01-04-04 09:16 PM


All times are GMT -5. The time now is 01:15 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.