Monday, March 2, 2015

Simple Way Send Data To Internet With Visual Basic .Net and PHP Web


Yes You can connect directly to remote sql server with visual basic .net also you can connect to remote mysql on the internet. You may send data to Internet via FTP or You can call the remote method via web service to send data via Internet.

In tis context I mean you can send data to the Internet with Visual Basic .NET and PHP web application by browse the web with internal browser apllication as usual.


here it is the picture off the web I run on my localhost



You can fill the data manually but In this project You will send the data automatically via sebbrowser component on your visual basic .net project

Below code of that php web:

<html>
<body>
<font  face="Courier New, Courier, monospace">
<p><strong>Send Data</strong></p>
<form name="frmdata" method="post">
  <p>Name:   
    &nbsp; &nbsp;&nbsp;&nbsp;
    <input type="text" id="txtName" name="name">
    <br>
    Profession:
  <input type="text" id="txtProfession" name="profession">
  </p>
  <p><br>
    <input type="submit" id="btnSubmit" value="send">
    </p>
</form>
</font>
</body>
</html>

<?php

if (isset($_POST["name"])) {
  if  ($_POST["name"]!=''){
      echo "Data was send"."<br/><br/>";
      echo "Name:".$_POST["name"]."<br/>";
      echo "Profession:".$_POST["profession"]; 
  }
}


?>



OK. Now You make  New Visual Basic Net Project with two label, two textbox, one button and one webbrowser component

Here it is then de design of yout project:


You can make code on form load event like this:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("localhost/send-data.php")
    End Sub


And You can make code form btnSend like this:
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click

        Dim Page As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
        For Each Element As HtmlElement In Page
            If Element.GetAttribute("id").Contains("txtName") Then
                Dim oTName As HtmlElement = Element
                oTName.InnerText = txtName.Text
            End If

            If Element.GetAttribute("id").Contains("txtProfession") Then
                Dim oTProfession As HtmlElement = Element
                oTProfession.InnerText = txtProfession.Text
            End If

            If Element.GetAttribute("id").Contains("btnSubmit") Then
                Dim oBtn As HtmlElement = Element
                oBtn.InvokeMember("click")
            End If
        Next
    End Sub


Below is the complete  code off your project:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("localhost/send-data.php")
    End Sub

    Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click

        Dim Page As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
        For Each Element As HtmlElement In Page
            If Element.GetAttribute("id").Contains("txtName") Then
                Dim oTName As HtmlElement = Element
                oTName.InnerText = txtName.Text
            End If

            If Element.GetAttribute("id").Contains("txtProfession") Then
                Dim oTProfession As HtmlElement = Element
                oTProfession.InnerText = txtProfession.Text
            End If

            If Element.GetAttribute("id").Contains("btnSubmit") Then
                Dim oBtn As HtmlElement = Element
                oBtn.InvokeMember("click")
            End If
        Next
    End Sub

End Class



Now You can run the project. The picture below is the right one:




Now You fill the data and then clik the seng button




After You clicked the send button Your data was send like the picture below:



OK guys Your Simple Way Send Data To Internet With Visual Basic .Net and PHP Web have done!
Feell fre to download Send Data To Internet With Visual Basic .Net and PHP Web click here

have a nice code :)


ok