I have a activity on Android Studio, grabbing information from JSON (that came from index.php), now I want to use this information on a new php page, so I can use it on a new query, to insert new values into phpmyadmin.
Here's the code from index.php
<?PHP
include_once("connection.php");
if(isset($_POST['txtEmail']) && isset($_POST['txtPassword'])){
$email = $_POST['txtEmail'];
$password = $_POST['txtPassword'];
$query = "SELECT * FROM tbl_user WHERE email = '$email'
AND password = '$password'";
$result = mysqli_query($conn, $query);
if($result->num_rows > 0){ //has record. correct username and password
while($row[] = $result->fetch_assoc())
{
$json = json_encode($row);
echo $json;
}
} else {
echo "0 results";
exit;
}
exit;
}
?>
Wich will display the JSON, what I want is to use one of the JSON fields (for example the ID returned) in a new query in another php page, for example in the WHERE statement.
To use the JSON on Android Studio and move it between activities I do the following:
JSONArray jArray = new JSONArray(s);
JSONObject json_data=null;
json_data = jArray.getJSONObject(0);
ct_name = json_data.getString("name");
ct_address = json_data.getString("address");
ct_email = json_data.getString("email");
ct_phone = json_data.getString("phone");
Bundle b = new Bundle();
b.putString("userdata",json_data.toString());
intent.putExtras(b);
startActivity(intent);
Another idea that I had was if I could grab the ID (field on the database), on the first php page (Index.php) and then use it on the second one, so it knows wich user is logged in at that time. I tried using Sessions to do this, but with no luck. Maybe because the php pages don't interact with eachother directly?