Building a messaging system for my site and i have been stuck for days. I have this `PHP` link 

`<a href='user_msg.php?hash=$hash'>$name</a>`

When you click on the link, it takes you to a page where you can send message to a user you've connected to (this connection is binded by the `$hash`)

in the page for sending the message, i hid the `$hash` in and hidden `input value="$hash"` and it sends the message to `row` in database with the `$hash` with the following `scripts` (They have no issue and work fine)

```
  var msg_area = $('.msg_area');
    msg_area.scrollTop(msg_area.prop("scrollHeight"));
        $('#send_rep').submit(function (e) {
            e.preventDefault();
            var $form = $(this), url = $form.attr('action');
            var posting = $.post(url, {rep_msg: $('#rep_msg').val(), hash: $('#hash').val()});
            posting.done(function (data) {
                alert('success');
            });
        });

```

**PHP script to send**

```
require_once ("db.php");
$db = new MyDB();
session_start();

if (isset($_POST['rep_msg']) && !empty($_POST['rep_msg']) || isset($_POST['hash']) && !empty($_POST['hash']))
{
$hash = (int)$_GET['hash'];
$my_id = $_SESSION['log_id'];
$rep_msg = $_POST['rep_msg'];
$hash = $_POST['hash'];

    $rsql = <<<EOF
INSERT INTO messager (message, group_hash, from_id) VALUES('$rep_msg', '$hash', '$my_id');
EOF;
    $rret = $db->exec($rsql);

    $ursql = <<<EOF
SELECT * FROM User WHERE ID = '$my_id';
EOF;

    $urret = $db->query($ursql);

    while ($urrow = $urret->fetchArray(SQLITE3_ASSOC)) {
        $from_fname = $urrow['fname'];
        $from_img = $urrow['image'];

        header('Location: user_msg.php?hash=' . $hash);
    }
}

```

The above `Ajax Request` and `php` script work fone to sedn the messages to database.

The issue not is getting the messages from database

This is the `script` i am currently using (not working)

**PHP script to get message**

```
require_once ("db.php");
$db = new MyDB();
session_start();

if (isset($_GET['hash']) && !empty($_GET['hash']))
{
$hash = (int)$_GET['hash'];
$us_id = $_SESSION['log_id'];

$mesql =<<<EOF
SELECT from_id, message FROM messager WHERE group_hash = '$hash';
EOF;
$meret = $db->query($mesql);
while ($merow = $meret->fetchArray(SQLITE3_ASSOC))
{
    $from_id = $merow['from_id'];
    $messages = $merow['message'];

    $usql =<<<EOF
SELECT * FROM User WHERE ID = '$from_id';
EOF;
    $uret = $db->query($usql);

    while ($urow = $uret->fetchArray(SQLITE3_ASSOC)) {
        $from_fname = $urow['fname'];
        $from_img = $urow['image'];

        if ($from_id != $_SESSION['log_id']) {

            echo "
<div class='from_bubble'><div class='from_img'><img src='$from_img'></div><div class='from_txt'><p>$messages</p></div></div>";
        } else {
            echo "
<div class='rep_bubble'><div class='rep_img'><img src='$from_img'></div><div class='rep_txt'><p>$messages</p></div></div>";
        }
    }
    echo "<input style='display: none' type='text' class='hash' name='hash' value='$hash' id='hash'>";
}
} 

```

Ajax Request

```
setInterval(function() {
    $('.msg_area').load("get_msg.php");
}, 2000);

```

But the get is not working. I suspect fro some reason, its not getting the `$hash`. Please is there a solution to this or am i trying something impossible. 

Any help would be appreciated. If more info is needed please ask. Thanks in advance