I am having a problem on how to get the id of the selected user along with it's information while I am logged in as an another user, using mysql, the two tables is innerjoined with each other I just dont know how to get the ID of other user, and passing it on other database
if(isset($_POST['send'])) {
$query = "SELECT * FROM tblmessage INNER JOIN tblusers ON tblmessage.userid=tblusers.userid";
$res = mysqli_query($con,$query);
while ($row = mysqli_fetch_assoc($res))
{
$receiverID = $row['userid'];
}
$sender = $_SESSION['Email'];
$receiver = $_POST['email'];
$message = $_POST['textmessages'];
$date = date("Y-m-d h:i:sa");
$q = 'INSERT INTO `tblmessage`(`id`,`sender_name`,`receiver_name`,`receiver_id`,`message_text`,`date_time`,`userid`)
VALUES("","'.$sender.'","'.$receiver.'","'.$receiverID.'","'.$message.'","'.$date.'","'.$user_id.'")';
$r = mysqli_query($con, $q);
if($r)
{
echo"<script>alert('Message Sent')</script>
<script>window.location.href='messages.php?id=$receiverID';</script>";
}
else
{
echo $q;
}
}