Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


pwaddles

113 posts

Master Geek


#19729 28-Feb-2008 12:02
Send private message

Hi guys,

I need a piece of code to automatically fill in a web form for me.  I've built a website for a client, but the host requires that we visit a certain page and type our credentials once a week into a sql registration page to allow him to access the sql servers.  Sounds crazy I know.

I've built everything thus far in VB.net so would like to keep using that but if I have to use something else to do this the so be it.

I've asked them (web host) if I can just pass some params into the address of the page but they said "No, No, No" (amy whinehouse)


Create new topic
 
 
 

Affiliate link: Shop computers and accessories at Lenovo.
RedJungle
Phil Gale
1108 posts

Uber Geek

Trusted
Red Jungle
Subscriber

  #113528 28-Feb-2008 12:54
Send private message

Note that this is untested:


Try

Dim web As New System.Net.WebClient()

      web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")

      Dim poststring As String = ""
      poststring = poststring & "myField1=foo&"
      poststring = poststring & "myField2=bar&"
      poststring = poststring & "myField3=etc"

      Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes(poststring)
      Dim res As Byte() = web.UploadData("http://www.yoursite.com/myform.aspx", "POST", d)

      MsgBox(System.Text.Encoding.ASCII.GetString(res)) 'Writes out resulting HTML response

Catch ex As Exception
     
        Dim strMessage As String
        strMessage = ex.ToString
        MessageBox.Show(strMessage, "Error Posting to Form", MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try





Red Jungle: we make fantastic software

RSS  Twitter  Facebook  Skype

pwaddles

113 posts

Master Geek


  #113531 28-Feb-2008 13:03
Send private message

now that looks like some sexy code, I'll try it out later on this evening. thanks

 
 
 
 


pwaddles

113 posts

Master Geek


  #113571 28-Feb-2008 15:34
Send private message

Hi redjungle,

I managed to do it in about 5 lines of code.

I created a new windows form, slapped a web browser onto it, pointed it at the desired website, then used

My.Computer.Keyboard.SendKeys() to input the necessary data.  This also lets my client see whats going on.


RedJungle
Phil Gale
1108 posts

Uber Geek

Trusted
Red Jungle
Subscriber

  #113573 28-Feb-2008 15:43
Send private message

Certainly one way to do it. Glad you accomplished what you wanted :)




Red Jungle: we make fantastic software

RSS  Twitter  Facebook  Skype

Create new topic




News »

Amazon introduces new Echo devices
Posted 25-Sep-2020 11:56


Mad Catz introduces new S.T.R.I.K.E. 13 Mechanical Gaming Keyboard
Posted 25-Sep-2020 11:34


Vodafone NZ upgrades international submarine network
Posted 25-Sep-2020 09:09


Jabra announces wireless noise-cancelling airbuds, upgrade existing model
Posted 24-Sep-2020 14:43


Nokia 3.4 to be available in New Zealand
Posted 24-Sep-2020 14:34


HP announces new HP ENVY laptops aimed at content creators
Posted 24-Sep-2020 14:02


Logitech introduce MX Anywhere 3
Posted 21-Sep-2020 21:17


Countdown unveils contactless shopping with new Scan&Go tech
Posted 21-Sep-2020 09:48


HP unveils new innovations for businesses adapting to rapidly evolving workstyles and workforces
Posted 17-Sep-2020 15:36


GoPro launches new HERO9 Black camera
Posted 17-Sep-2020 09:45


Telecommunications industry launches new 5G Facts website
Posted 17-Sep-2020 07:56


New Zealand ranks 3rd in world in GSMA index
Posted 15-Sep-2020 10:13


Trend Micro Security Suite adds web monitoring to prevent identity theft
Posted 14-Sep-2020 15:37


NVIDIA to acquire Arm for US$ 40 billion
Posted 14-Sep-2020 12:27


Epson launches its next gen A3+ colour EcoTank multi-function printer
Posted 10-Sep-2020 16:08



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.


Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.