Dear sir,
I have a B4A code to pass variable from B4A to php and upload my sqli database.Below is all my code. My programe could update one variable eg. nameEdit.Text however,
I do not know how to pass two variable from B4A to php.
The following work when pass one variable Name, but I don't know how to pass another variable name 'Phone ' to the php at the same time.
savedata.PostString("https://www.repairfairyhk.com/upPost.php","save=&Name="&nameEdt.Text )
Thanks for your kind help.
Mak
/*******************************************************************************************
B4A Code :
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Button1 As B4XView
Dim imageSelectedList As List
Private Panel1 As B4XView
Private ImageView1 As ImageView
Private ImageView2 As ImageView
Private ImageView3 As ImageView
Dim xui As XUI
Private upLoadBtn As B4XView
Private nameEdt As EditText
Private phoneNumEdt As EditText
Private detailEdT As B4XView
Dim savedata As HttpJob
End Sub
savedata.Initialize("savedata",Me)
savedata.PostString("https://www.repairfairyhk.com/upPost.php","save=&Name="&nameEdt.Text )
Sub jobDone(job As HttpJob)
'save data
Select job
Case savedata
If job.Success Then
'success message
ToastMessageShow("Saved ",False)
nameEdt.Text = ""
phoneNumEdt.Text=""
Else
ToastMessageShow("Check your internet connection",False)
End If
savedata.Release
End Select
[/CODE]
I have a B4A code to pass variable from B4A to php and upload my sqli database.Below is all my code. My programe could update one variable eg. nameEdit.Text however,
I do not know how to pass two variable from B4A to php.
The following work when pass one variable Name, but I don't know how to pass another variable name 'Phone ' to the php at the same time.
savedata.PostString("https://www.repairfairyhk.com/upPost.php","save=&Name="&nameEdt.Text )
Thanks for your kind help.
Mak
Code:
<?php
#connect to database
// information on server
$servername="localhost";
$username = "repairfair_memberLog";
$password = "Rf70939";
$databaseName = "repairfair_member"; //DataBase name
//Create Connection
$mysqli= new mysqli($servername,$username,$password,$databaseName);
if($mysqli-> connect_error){
die("Connection failed: ".$mysqli-> connect_error);
}
//Save Data
if(isset($_POST['save'])){
$name=$_POST['Name'];
$sql = "INSERT INTO test(Name) VALUES ('$name')";
//Execute to insert data
if($mysqli->query($sql) == True){
die("Data Saved !");
}else{
die("Error:". $sql. "<br>". $mysqli-> error);
}
//Close connection
$mysqli->close();
}
?>
/*******************************************************************************************
B4A Code :
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Button1 As B4XView
Dim imageSelectedList As List
Private Panel1 As B4XView
Private ImageView1 As ImageView
Private ImageView2 As ImageView
Private ImageView3 As ImageView
Dim xui As XUI
Private upLoadBtn As B4XView
Private nameEdt As EditText
Private phoneNumEdt As EditText
Private detailEdT As B4XView
Dim savedata As HttpJob
End Sub
savedata.Initialize("savedata",Me)
savedata.PostString("https://www.repairfairyhk.com/upPost.php","save=&Name="&nameEdt.Text )
Sub jobDone(job As HttpJob)
'save data
Select job
Case savedata
If job.Success Then
'success message
ToastMessageShow("Saved ",False)
nameEdt.Text = ""
phoneNumEdt.Text=""
Else
ToastMessageShow("Check your internet connection",False)
End If
savedata.Release
End Select
[/CODE]