Link to home
Start Free TrialLog in
Avatar of altiplano
altiplano

asked on

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,
Avatar of Leigh Purvis
Leigh Purvis
Flag of United Kingdom of Great Britain and Northern Ireland image

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 ;-)
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
Avatar of altiplano
altiplano

ASKER

>> 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,
ASKER CERTIFIED SOLUTION
Avatar of flavo
flavo
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ha - Dave's just got in there before I posted a link to that kind of example!

Oh well - there you have it :-)
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
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 :-)
>now I can go off for a relaxed lunch :-)
That sounds like a plan.. A pint or 3 it is :D
>> That sounds like a plan.. A pint or 3 it is :D

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

They do?
Sheesh.
> 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.
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 )
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)?