Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft web browser control for VFP

Status
Not open for further replies.

noel cris

Programmer
Dec 22, 2020
4
0
0
PH
In the microsoft web browser control I have tried appending parameters in the URL itself and it works. The problem is that the size is limited for the querystring. So I would like to know how the use the parameters especially the postdata parameter in the navigate method of the control. I tried to pass a string but was not detected by PHP.

*
* this one works
thisform.oBrowser.Navigate("
* this one doesn't
postdata='action=putsession&value=test'
header= "Content-Type: application/x-thisform.oBrowser.Navigate(" '','',postdata, header)

What is the correct syntax?
Thanks experts
 
I think you are missing one of the optional parameters. The calling sequence for Navigate2 is as follows:

Code:
Navigate2(URL, Flags, [highlight #FCE94F]TargetFrameName,[/highlight] PostData, Headers)

The TargetFrameName is something like _blank. It is optional, so you can pass an empty string, but you must include it if you also want to sed the post data and the header.

See also
By the way, you should normally use Navigate2 rather than Navigate (for some reason which I can't remember).

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,
Thank you for your response.
The link you gave is 404 to me.
In my example which is not working the flags and targetframe was set to '' (empty string).
I changed the method to Navigate2 and it still didn't work.
Can you send me a sample snippet?
Please help me. I am desperate.
thanks a lot.
 
Hi Noel,

In fact the link was correct. The problem was that the Tek Tips software chopped off the final end parenthesis. If you were to click on the link again, and manually add [highlight #FCE94F])[/highlight] to the end of the URL, it will get to the correct page.

That said, having had a closer look at your code, I can see that you did include the optional parameters after all. I mistook '' for " - an easy mistake.

I'm sorry I don't have a code snippet that includes the post data and header. It might help if you could tell us exactly what happens when you run your code.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Try this:

Code:
Thisform.olecontrol1.Navigate2('localhost/post.php', '', '', CREATEBINARY('test=42'), 'Content-Type: application/x-www-form-urlencoded')

Code:
<?php var_dump($_POST); ?>

It works for me, the webbrowser displays [tt]array(1) { ["test"]=> string(3) "42" }[/tt]. Why? I can't say for sure, but casting the postdata as binary was one of the bag of tricks you learn. It's not always working, but in this case I guess it tricks OLE marshalling of types.

Chriss
 
Hi chriss
thank you for your reply.
the line createbinary(test=42) works but what I tried using 2 parameters like (test=42&test1=43)
It didn't get the second parameter. How do I separate parameters?
thanks

 
Code:
test=42&test1=43

Exactly that way. Just remember & (the ampersand) also has a special meaning in VFP as macro substitution. So when a variable test1 exists and you have &test1 in the post body string, that'll be replaced by test1 variable value.

So to make sure you get a separate ampersand use CHR(38):

Code:
Thisform.olecontrol1.Navigate2('localhost/post.php', '', '', CREATEBINARY('test=42'+chr(38)+'test1=43'+chr(38)+'testx=99'), 'Content-Type: application/x-www-form-urlencoded')

Edit: It should be obvious to a PHP or web dev...
The parameterstring has to be url-encoded as the Content-Type promises such a format. CREATEBINARY doesn't change that, it just ensures the string is kept as is on the way from VFP code to the OLE control. Which in short means, URL-escape your parameeter string and then finally use CREATEBINARY on it.

By the way, there are other Content-Types you#re able to set and then can also post other body formats, like Content-Type: application/json, where the body then has to be JSON, which rarely contains ampersands.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top