hyperlink to pass info to web login page

iankerry

Registered User.
Local time
Today, 19:45
Joined
Aug 10, 2005
Messages
190
Hi All

I run a small charity and we have about 100 people (promoters) who login to our website.

i store all their passwords and login names on our SQL server (which feeds the website).

As all this is quite new, I am finding myself logging as different promoters to check their account.

I can create a hyperlink to the login page - but i want to be able to pass the username and passwrod to the login page, as i have this information.

can this be done?

Thanks
ian
 
They name their elements very well which makes it easy.

Here you go.

Code:
Dim ie As Object
Set ie = CreateObject("internetexplorer.application")

ie.Visible = True

ie.navigate "http://www.artsalive.co.uk/promoter-login.aspx"

'wait for the html to be there.
While ie.busy
    DoEvents
Wend

'add username
ie.Document.getElementById("ctl00$ContentPlaceHolder1$txtUsername").Value = "username"

'add password
ie.Document.getElementById("ctl00$ContentPlaceHolder1$txtPassword").Value = "password"

'click on the submit button
ie.Document.all("ctl00$ContentPlaceHolder1$btnGo").Click

Set ie = Nothing
 
wow, that worked a treat!

You are awesome!

Many thanks

Ian
 
worked out a little better than our last thread.

Your welcome.
 
hi

sorry to reopen this thread, but for the last few weeks the code has stopped working! I just checked and it is just the same as before.

now when i hit the "login as promoter button" i get a runtime error 424 Object required on:

ie.Document.getElementById("ctl00$ContentPlaceHolder1$txtUsername").Value = [username]

has ie updated itself and now won't run the code?

the only other clue was when i put a watch on the line - it says "automation error - the oject invoked has disconneted from its clients"

anyone any ideas?

thanks
 
is the document fully loaded in IE before you are running your code?

does "ctl00$ContentPlaceHolder1$txtUsername" still exist or have they changed it?
 
Hi Darbid

I dont quite understand the question. if you remember (as you helped me create it!) this routine loads a webpage then gets the username and password from the access database.

thanks

ian
 
before you run your script load the first webpage and then let it sit there for 20 seconds or so. ie make sure that it has totally finished loading the page. Then do you get the error.

Second - look at the HTML source and search for the above word, is it still there. Maybe the web page has changed.
 
Hi Darbid

yes i get the error if i have already loaded the page - though the script open a new ie window and doesnt use that one.

i noticed that the username and password fields (below) are have correctly obtained the two values from the database.


'add username
ie.Document.getElementById("ctl00$ContentPlaceHolder1$txtUsername").Value = [username]

'add password
ie.Document.getElementById("ctl00$ContentPlaceHolder1$txtPassword").Value = [password]


any thoughts?

ian
 
no i dont understand you.

is the code working at all, sometimes or never. If you stop the code from running until you are sure the page has fully loaded, does it then work? Are the fields filled with text?
 
ok, i'll try and be clearer. below is the code and i got it to pause on each line and have commented on what is happening.

Dim ie As Object
Set ie = CreateObject("internetexplorer.application")

ie.Visible = True

LOADS IEXPLORER

ie.navigate "http://www.artsalive.co.uk/promoter-login.aspx"

GOES TO THE WEBSITE PAGE

'wait for the html to be there.
While ie.busy
DoEvents
Wend

WAITS FOR PAGE TO COME UP _ WHICH IT DOES SUCCESSFULLY. TWO FIELDS ON THE PAGE ARE AWAITING INFORMATION

'add username
ie.Document.getElementById("ctl00$ContentPlaceHolder1$txtUsername").Value = [username]

AT THIS POINT TO CODE STOPS WITH RUN TIME ERROR 424 OBJECT REQUIRED. WHEN I PUT MY CURSOR OVER THE LINE OF CODE I CAN SEE THE [USERNAME]. I CHECKED THE SOURCE CODE ON TYHE WEBSITE AND THE FIELD NAME MATCHES THE ct100$contentplaceholder FIELD

IT ALWAYS STOPS AT THIS PLACE

NO THE FIELDS DON'T GET FILLED WITH TEXT.

THE PAGE IS DEF UP AND WAITING FOR THE CODE TO WORK.


hope that's clearer, thanks.

Ian
 
I just copied my code from post 4 into a new mdb and ran it. It worked fine. IE was closed, it was the openend, navigated to the page and worked ok.
 
Hi Darbid

I am wondering if one of my references has become corrupt. Which Reference do you need to run this code?

thanks

ian
 
here is my test mdb. It is a brand new mdb with no added references.
 

Attachments

Hi Darbid

thanks again for your perseverance.

that code comes up with exactly the same error

run time error 424 - object required.

so it isn't the code - it must be on the website....

hooorrrrayyyy. nothing has changed on the website, the code has always used the two controls on the site with have a NAME. But when i amended the code thew point to the two input boxes called ID - it worked!!!

thanks Darbid, another success.
 

Users who are viewing this thread

Back
Top Bottom