The problem is when you submit the form, you lose the query string ($_GET['UserID']). To fix this, change your action on your form to say:
action="messaging_Insert.php?UserID=<?php $_GET['UserID']; ?>"
You might want to add an isset() around it if there is a case where a use comes to this page with no userid in the url.