1

Hi I'm trying to pass a value from Vb to PHP. So far I have used public property to pass a string value to one form to another

        Public _passedText As String
        Public Property PassedText() As String
    Get
        Return _passedText
    End Get
    Set(ByVal Value As String)

        TextBox1.Text = Value
        User.Text = Value
    End Set
End Property

I would like the same value to be passed to a php file is this possible? Also I'm using WinForms

deceze
  • 510,633
  • 85
  • 743
  • 889
  • Need more details. Is the PHP on an external server or the same machine as the VB code is executed, do you want to run the PHP via command line or call it through a URL? – MrCode Apr 30 '12 at 15:50
  • It's on the same machine and I would like to call it via URL – user1356182 Apr 30 '12 at 15:51
  • Have a look at HttpWebRequest: http://www.vbdotnetheaven.com/Uploadfile/mahesh/DownloadWebPage04252005073432AM/DownloadWebPage.aspx – MrCode Apr 30 '12 at 16:17

2 Answers2

0

You could use the HTTP protocol to comunicate with the PHP Server . In c# this communication can be achieved using the HttpWebRequest Class.

Encapsulating the data you wish to send via POST or GET methods

HttpWebRequest Class

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx#Y0

HttpWebRequest POST

http://www.netomatix.com/httppostdata.aspx

HttpWebRequest GET

How do I use HttpWebRequest with GET method

On the PHP Side you would extract the parameters you transferred. The method of parameter extraction will depend on weather you used POST or GET to send data to the server.

PHP GET

http://php.net/manual/en/reserved.variables.get.php

PHP POST

http://www.w3schools.com/php/php_post.asp

And once you got your parameters on PHP server side you proceed doing something with them.

Read more about PHP in general

http://php.net/manual/en/index.php

And about the HTTP Protocol.

http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

good luck

Community
  • 1
  • 1
Alex
  • 768
  • 1
  • 5
  • 13
0

If your winform and php server (e.g. apache server) located in a same machine, then you can pass value from winform to php using a file. Winform saves the value to be passed onto php into a file and php read the saved file.

Teen
  • 721
  • 3
  • 5