Click here to Skip to main content
15,886,771 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
hi code project member,
i have a code that send data from vb.net to PHP. but after get the data from vb.net,it will update database mysql. the problem i have is after update in mysql,how to tell the vb.net that i had updated my database..

here is my code.

activate.php
PHP
<?php
$serialnum = $_GET['ser'];
$company_name = $_GET['comp'];
$date_activate = date("Y-m-d");

$check = mysql_query("SELECT * FROM license WHERE serialnumber = '$serialnum' && status = 'DEACTIVATED'");

if($check)
{
	if(mysql_num_rows($check) == 1)
	{
	//if exist in table license,update column status = 'activate' and date_activate = now(), check again in table activate
	//check in table activate
	//if exist,means it already activate
        //if not exist,insert into table activate and
        //the problem is here how to tell vb.net that i already update database
	}
	else
	{
	//the problem is here to,how to tell vb.net that data is exist 
	
	}
}
else
{
//the problem is here to,how to tell vb.net that query failed
}
?>

this is my script in vb.net

activatefrm.vb
VB
Private Sub activateBtn_Click(sender As Object, e As EventArgs) Handles activateBtn.Click
        Process.Start("http://localhost/license/activate.php?ser=" & serialnum.Text & "&&comp=" & compname.Text)   
    End Sub

i hope codeproject member can help me. thank you.
Posted
Updated 16-Oct-19 0:55am
v2

Hello,

Process.Start is not the right way to call PHP or for that matter any web resource. You need to use System.Net.HttpWebRequest instead. Here is a small snippet to demonstrate how it's done. From your PHP page you can either send tour data in CSV format, or name=value pair on each line format, or JSON format or even XML. The choice is yours.
VB
Dim strReq As String
Dim strData As String
Dim dataStream As Stream 
Dim reader As StreamReader
Dim request As WebRequest
Dim response As WebResponse

strReq = "http://localhost/license/activate.php?ser=" & serialnum.Text & "&&comp=" & compname.Text
request = WebRequest.Create(strReq)
response = request.GetResponse()
dataStream = response.GetResponseStream()
reader = New StreamReader(dataStream)
strData = reader.ReadToEnd()
reader.Close()
response.Close()

Regards,
 
Share this answer
 
Comments
xana7900 1-Apr-13 2:17am    
can u give example how to send data in xml and communicate between vb and xml?
Prasad Khandekar 1-Apr-13 7:01am    
It's simple just create a string by conatenation. e.g. $xml = "<root><fname>" . $first_name . "". Then echo this string as response form PHP.
xana7900 1-Apr-13 22:57pm    
i have update my question...i want ask how to tell vb.net after updated my database.is it possible to tell vb.net from php?
Prasad Khandekar 2-Apr-13 10:16am    
One simple way is if your PHP processing is successful send a string "SUCCESS" in response or send "FAILED". in vb.net you can then take appropriate action. Agiain Process.Start is not a mechanism to be used for this purpose. Look at my solution.
xana7900 2-Apr-13 20:55pm    
thanks..u really help me a lot...
hy guys any one knw about how mysql database table nd ms sql databse attach with each other
 
Share this answer
 
Comments
Richard Deeming 16-Oct-19 15:39pm    
Your question is not a "solution" to someone else's question.

If you want to ask a question, then ASK A QUESTION[^]. But you're going to have to provide a lot more information than you have here if you want anyone to be able to help you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900