I would like you to help me I am making a mobile application and I have two tables in my database one called "users" and the other "activities" inside this second table I have a foreign key of the user id, what I want is get the id of the logged in user and insert it in the activities table, every time a user posts an activity
I leave the php code I use to make an insert in the table activities
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
$imagen= $_POST['foto'];
$nombre = $_POST["Titulo"];
$des = $_POST["Descripcion"];
$aut = $_POST["Autor"];
$fec = $_POST["Fecha"];
$hor = $_POST["Hora"];
require_once('../registro/Conexion_db.php');
$sql ="SELECT idActividad FROM actividades ORDER BY idActividad DES";
$res = mysqli_query($con,$sql);
$id = 0;
while($row = mysqli_fetch_array($res)){
$id = $row['idActividad'];
}
if($imagen!="no imagen"){
$path = "uploads/$id.png";
$actualpath = "https://pitav2.000webhostapp.com/$path";
$sql = "INSERT INTO actividades (foto,titulo,descripcion,autor,fecha_entrega,hora_entrega) VALUES ('$actualpath','$nombre','$des','$aut','$fec','$hor')";
}else{
$actualpath = "sin imagen";
$sql = "INSERT INTO actividades (foto,titulo,descripcion,autor,fecha_entrega,hora_entrega) VALUES ('$actualpath','$nombre','$des','$aut','$fec','$hor')";
}
if(mysqli_query($con,$sql)){
file_put_contents($path,base64_decode($imagen));
echo "Subio imagen Correctamente";
}
mysqli_close($con);
}else{
echo "Error";
}