Dear all.
The setup is the following:
I am trying to make an android app communicate with my MySql database Server (which for now is on localhost:3308).
On the client side I have created the following code:
dataString = {uname: uname.value, pass: pass.value, email:email.value};
When a button is clicked, the code gathers the necessary information and send it to register.php.
$.ajax({
type: "GET",
url: "register.php",
data: dataString,
cache: false,
success: function(d){
alert(d);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + errorThrown);
}
});
register.php:
<?php
// Get the data from the client.
$servername = "localhost:3308";
$username = "root";
$password = "";
$dbname = "housecontrol";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO 'users'(user_name,password,user_id,email,full_name,address,telephone,comments) VALUES ('john','1234','john73','m@dd.gr','john smith','Johnson Str','+0177748883','blah blah')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
- Where should the register.php reside? In the www root folder of the apache server? Somewhere else?
- In short, what does it take to make an app, running from an X network, communicate with a MySQL DB in a Y network?