I currently followed a tutorial for a public user chat where it uses Msg\_ID, Sender, Message. Sender being the name. I currently have a friend table where:
ID, my\_id, friend\_id. 
But am unsure how to alter the chat so it's only sent to the recipient vice versa. And I have changed the chat table to the following: Msg\_id, Author\_id, Recipient\_id, Message.
The current query for the chat is:

```html
<?php

    function get_msg() {

        $query = "SELECT `Author_ID`, `Message` FROM `pdo_ret`.`chat` ORDER BY `Msg_ID` ASC";

        $run = mysql_query($query);

        $messages = array();

        while($message = mysql_fetch_assoc($run)) {
            $messages[] = array('Author_ID'=>$message['Author_ID'],
                                'message'=>$message['Message']);
        }

        return $messages;

    }

    function send_msg($Author_ID, $message) {

        if(!empty($Author_ID) && !empty($message)) {

            $Author_ID  = mysql_real_escape_string($Author_ID);
            $message    = mysql_real_escape_string($message);

            $query = "INSERT INTO `pdo_ret`.`chat` (Msg_ID, Author_ID, Message) VALUES (null, '{$Author_ID}', '$message')";

            if($run = mysql_query($query)) {
                return true;
            } else {
                return false;
            }

        } else {
            return false;
        }
    }

?>

```

While the form for the chat is:

```html
                        <form action="#" method="post" onsubmit="return InsertDefaultValues()"  id="form_input">
                            <input hidden type="text" name="Author_ID" id="Author_ID"/>
                            <input hidden type="text" name="friend_id" id="friend_id"/>
                            <input type="text" id="message" cols="5" rows="4"></textarea>
                        <input type="submit" name="send"  onsubmit="return InsertDefaultValues()"  id="send" value="Send Message"/>
                        </form>

```

Here is my script for the session which I'm trying to use to define the user that is logged in.

```html
<?php
session_start();
if(!isset($_SESSION["user"]) or !is_array($_SESSION["user"]) or empty($_SESSION["user"]));
?>
```