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

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 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
Phil Gale
1108 posts

Uber Geek
+1 received by user: 45

Red Jungle

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

Note that this is untested:


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("", "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

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


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.

Phil Gale
1108 posts

Uber Geek
+1 received by user: 45

Red Jungle

  # 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

Twitter and LinkedIn »

Follow us to receive Twitter updates when new discussions are posted in our forums:

Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:

Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:

News »

Air New Zealand uses drones to inspect aircraft
Posted 17-Jun-2019 15:39

TCL Electronics launches its first-ever 8K TV
Posted 17-Jun-2019 15:18

E-scooter share scheme launches in Wellington
Posted 17-Jun-2019 12:34

Anyone can broadcast with Kordia Pop Up TV
Posted 13-Jun-2019 10:51

Volvo and Uber present production vehicle ready for self-driving
Posted 13-Jun-2019 10:47

100,000 customers connected to fibre broadband network through Enable
Posted 13-Jun-2019 10:35

5G uptake even faster than expected
Posted 12-Jun-2019 10:01

Xbox showcases 60 anticipated games
Posted 10-Jun-2019 20:24

Trend Micro Turns Public Hotspots into Secure Networks with WiFi Protection for Mobile Devices
Posted 5-Jun-2019 13:24

Bold UK spinoff for beauty software company Flossie
Posted 2-Jun-2019 14:10

Amazon Introduces Echo Show 5
Posted 1-Jun-2019 15:32

Epson launches new 4K Pro-UHD projector technology
Posted 1-Jun-2019 15:26

Lenovo and Qualcomm unveil first 5G PC called Project Limitless
Posted 28-May-2019 20:23

Intel introduces new 10th Gen Intel Core Processors and Project Athena
Posted 28-May-2019 19:28

Orcon first to trial residential 10Gbps broadband
Posted 28-May-2019 11:20

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.