I am working on an android app on which I take Application ID and Applicant Name from the user as an input value for authentication which is matched from an MYSQL database using PHP to get to the next screen on connection success
login.php
<?php
session_start();
require "conn.php";
$user_name = $_POST["user_name"];
$user_id = $_POST["id"];
$mysql_qry = "select * from complaints where Applicant_Name = '".$user_name."' and Complaint_ID like '".$user_id."';";
$result = mysqli_query($conn, $mysql_qry);
if (mysqli_num_rows($result) > 0){
$_SESSION["username"] = "$user_name";
$_SESSION["userid"] = "$user_id";
echo "Login Success";
}
else {
echo "Login Not Success";
}
?>
Now on next screen, I want to show the content related to that particular Application ID and Applicant Name for which I want to use the value of variable $user_name and $user_id from login.php in WHERE part of query of content.php to fetch the particular data I require.
Right now I am using the code below which is working fine right now but I want to use the value of $user_name and $user_id to use in WHERE part of content.php query
content.php
<?php
session_start();
require "conn.php";
$username = $_SESSION["username"];
$userid = $_SESSION["userid"];
//creating a query
$stmt = $conn->prepare("SELECT Complaint_ID, Applicant_Name, Category, Subject, Description FROM complaints WHERE Complaint_ID = '".$userid."' AND Applicant_Name = '".$username."'");
//executing the query
$stmt->execute();
//binding results to the query
$stmt->bind_result($id, $name, $cat, $sub, $desc);
$complaint = array();
//traversing through all the result
while($stmt->fetch()){
$temp = array();
$temp['Complaint_ID'] = $id;
$temp['Applicant_Name'] = $name;
$temp['Category'] = $cat;
$temp['Subject'] = $sub;
$temp['Description'] = $desc;
array_push($complaint, $temp);
}
//displaying the result in json format
echo json_encode($complaint);
?>
On android there is no issue every thing is working fine its the PHP side I need Help.