I'm trying to make a system of private messages in PHP, at the moment I have managed to show the private messages that a user has, with the following code:
<div>
<?php
require_once "messages.php";
//obtengo todos los mensajes privados del usuario con id=3 (de prueba)
$private= Usuarios::GetPrivate(3);
//obtengo el usuario que escribió cada mensaje
foreach ($private as $priv) {
$id= $priv->emisor_id;
$usuario = Usuarios::GetUser($id);
//imprimo el usuario
foreach ($usuario as $usu){
echo $usu->user;
echo "<br>";
?>
//incluyo un botón para responder
<input type="submit" value="<?php echo "responder a ".$usu->user ?>" name="button" id="button">
<?php
}
//imprimo el mensaje
echo $priv->message;
echo "<br>";
?>
-----------------------------------------------------
<br><br>
</div>
I would like to know if someone could give me some indication on how to do so that the user can respond directly to a private message. The table of private messages has the fields id, message, emitter_id and receiver_id. Should I add some more field?