Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP VB.NET
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
$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
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 31-Mar-13 19:37pm
Edited 1-Apr-13 17:55pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
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,
  Permalink  
Comments
xanesa at 1-Apr-13 2:17am
   
can u give example how to send data in xml and communicate between vb and xml?
Prasad Khandekar at 1-Apr-13 7:01am
   
It's simple just create a string by conatenation. e.g. $xml = "" . $first_name . "". Then echo this string as response form PHP.
xanesa at 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 at 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.
xanesa at 2-Apr-13 20:55pm
   
thanks..u really help me a lot...

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



Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 1 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100