How to POST data from VBA

Hi experts,

I'm trying to POST data from an MS Access application to a php page on my website and I just can't get it working. Has anyone a simple but working example of how to use FollowHyperlink with msoMethodPost (or any other POSTing technique)?

What I'm trying to achieve is that users can automatically log-in into the bugtracker at http://www.altiplano-ict.nl/bugs/login_page.php. The application knows the uid & password and should launch the browser when clicked on the "report a bug" button.

thanks,
altiplanoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Leigh PurvisDatabase DeveloperCommented:
Is there not a simple querystring that is appended to this?

http://www.altiplano-ict.nl/bugs/login_page.php?UN=xxx&PW=xxx

Alternatively (and somewhat more neatly) you can use the MSXML library to make posts to an address.
There's no string limit then either (though I strongly suspect that isn't an issue for you here ;-)
Leigh PurvisDatabase DeveloperCommented:
Add a reference to the MSXML library - version 3 or newer
Then something like

Dim req As New MSXML2.XMLHTTP

strAddress = "http://www.altiplano-ict.nl/bugs/login_page.php"
strPost = "UN=" & strUN & "&PW=" & strPW
With req
    .Open "POST", strAddress, False
    .setRequestHeader "Content-Type", "application/x-www-form-urlencoded" '"text/xml"
    .Send strPost
End With
altiplanoAuthor Commented:
>> Is there not a simple querystring that is appended to this?
>> http://www.altiplano-ict.nl/bugs/login_page.php?UN=xxx&PW=xxx

Unfortunately not. I could probably rewrite login.php as to also accept the query string, but since I didn't develop the bugtracker I'm a bit hesistant to do that. I would rather POST the data if possible.

Do you have an example using the MSXML library?

thanks,
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

flavoCommented:
Something like this:

You need references set to:
Microsoft Internet Controls
and
Microsoft HTML Onject Library

    Dim ie As SHDocVw.InternetExplorer
    Dim h As MSHTML.HTMLDocument
   
    Set ie = New SHDocVw.InternetExplorer
   
    ie.Navigate2 "http://www.altiplano-ict.nl/bugs/login_page.php"
   
    While ie.Busy
        DoEvents
    Wend
   
   
    Set h = ie.Document
   
    h.Forms("login_form").Item("username").Value = "myUserName"
    h.Forms("login_form").Item("Password").Value = "myPassword"
    h.Forms("login_form").submit

    ie.Visible = True

Dave

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Leigh PurvisDatabase DeveloperCommented:
Ha - Dave's just got in there before I posted a link to that kind of example!

Oh well - there you have it :-)
flavoCommented:
There weren't any posts when I started to try remember how to do it :P

Didn't know about the MSXML Lib being able to do such things.. :D
altiplanoAuthor Commented:
Gosh, and people really complain about Experts-Exchange being too expensive? You just saved me a years worth of subscription fees to EE!

Thanks a 10^6, now I can go off for a relaxed lunch :-)
flavoCommented:
>now I can go off for a relaxed lunch :-)
That sounds like a plan.. A pint or 3 it is :D
altiplanoAuthor Commented:
>> That sounds like a plan.. A pint or 3 it is :D

Yep, 3 pints for me as well :D
Leigh PurvisDatabase DeveloperCommented:
"people really complain about Experts-Exchange being too expensive" ??

They do?
Sheesh.
altiplanoAuthor Commented:
> They do?
> Sheesh.

Well, not directly. But just for a laugh, do a search for "I only have points". You'll literally find hundreds of questions with some variation on "I have this very urgent an complicated question but only 25 points. Please help". If it really is this important and urgent just shell out the $10, which in my opinion is still a steal. I probably could have figured out this question myself, but it would have taken me, say, 4 hours to get it working. Now I got an excellent answer in less than 15 miutes.
Leigh PurvisDatabase DeveloperCommented:
Yeah - I am probably guilty of taking pity on those that report being low on points - but unless they're very poor (in which case then excellent that I've helped) then it isn't a huge ask.
I suppose the thing for those questioners to bear in mind is that the cost of EE must be kept out of mind when dealing with the experts.
We do it entirely separately of all those shenanigans.

To make the world a better place and bring the human race together as one.

(Are you drinking yet Dave - sounds like I've started :-S )
altiplanoAuthor Commented:
Since I've got your attention now :) do you have any idea how I can maximize the IE window once it's opened (or do you want me to open a new question for this)?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.