PHP Post not working

I have these 2 codes, for some reason it wont output my variables using POST can anybody please help


include "database.php";
$loggeduser=vB::$vbulletin->userinfo['username'];
$output .= <<<JS
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!

try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var username = document.getElementById('username').value;
var userlevel = document.getElementById('userlevel').value;
ajaxRequest.open("POST", "test.php" , true);
ajaxRequest.send(null);
}
//-->
</script>
JS;

$output .= '<form name=myForm method=post>';
$output .= 'UserName: <input type=text id=username /> UserLevel: <select id=userlevel>';
$output .= '<option value=2>Member</option>';
$output .= '<option value=7>Moderator</option>';
$output .= '</select>';
$output .= '<input type=button onclick=ajaxFunction() value=Update User />';
$output .= '</form>';
$output .= '<div id=ajaxDiv>';

$result = mysql_db_query($dbname, "SELECT * FROM member WHERE MemberType = '5' or MemberType = '4' order by username asc ");
$output .='<b>Administrators:</b><br>';
if (mysql_num_rows($result)) {
   while ($qry = mysql_fetch_array($result)) {

$query2 = mysql_query("SELECT * FROM member WHERE UserName='$qry[UserName]' ")
or die("Could not insert data because ".mysql_error());
$qry2 = mysql_fetch_array( $query2 );

$query4 = mysql_query("SELECT * FROM onlineusers WHERE UserName='$qry[UserName]' ")
or die("Could not insert data because ".mysql_error());
$qry4 = mysql_fetch_array( $query4 );

$query3 = mysql_query("SELECT * FROM room WHERE RoomID='$qry4[RoomID]' ")
or die("Could not insert data because ".mysql_error());
$qry3 = mysql_fetch_array( $query3 );

if (mysql_num_rows($query4) == 0) {
$status = "Offline";
}
else
{
$status = "$qry3[RoomName]";
}
$output .="<img src=images/icons/admin.png> $qry[UserName] <a href=member.php?$qry2[MemberID]-$qry2[UserName]>[View Profile]</a> ($status)<br>";
}
}

$result = mysql_db_query($dbname, "SELECT * FROM member WHERE MemberType = '3' order by username asc ");
$output .='<br><b>Senior Moderators:</b><br>';
if (mysql_num_rows($result)) {
   while ($qry = mysql_fetch_array($result)) {

$query2 = mysql_query("SELECT * FROM member WHERE UserName='$qry[UserName]' ")
or die("Could not insert data because ".mysql_error());
$qry2 = mysql_fetch_array( $query2 );

$query4 = mysql_query("SELECT * FROM onlineusers WHERE UserName='$qry[UserName]' ")
or die("Could not insert data because ".mysql_error());
$qry4 = mysql_fetch_array( $query4 );

$query3 = mysql_query("SELECT * FROM room WHERE RoomID='$qry4[RoomID]' ")
or die("Could not insert data because ".mysql_error());
$qry3 = mysql_fetch_array( $query3 );

if (mysql_num_rows($query4) == 0) {
$status = "Offline";
}
else
{
$status = "$qry3[RoomName]";
}
$output .="<img src=images/icons/srmod.png> $qry[UserName] <a href=member.php?$qry2[MemberID]-$qry2[UserName]>[View Profile]</a> ($status)<br>";
}
}

$result = mysql_db_query($dbname, "SELECT * FROM member WHERE MemberType = '2' order by username asc ");
$output .='<br><b>Moderators:</b><br>';
if (mysql_num_rows($result)) {
   while ($qry = mysql_fetch_array($result)) {

$query2 = mysql_query("SELECT * FROM member WHERE UserName='$qry[UserName]' ")
or die("Could not insert data because ".mysql_error());
$qry2 = mysql_fetch_array( $query2 );

$query4 = mysql_query("SELECT * FROM onlineusers WHERE UserName='$qry[UserName]' ")
or die("Could not insert data because ".mysql_error());
$qry4 = mysql_fetch_array( $query4 );

$query3 = mysql_query("SELECT * FROM room WHERE RoomID='$qry4[RoomID]' ")
or die("Could not insert data because ".mysql_error());
$qry3 = mysql_fetch_array( $query3 );

if (mysql_num_rows($query4) == 0) {
$status = "Offline";
}
else
{
$status = "$qry3[RoomName]";
}
$output .="<img src=images/icons/moderator.png> $qry[UserName] <a href=member.php?$qry2[MemberID]-$qry2[UserName]>[View Profile]</a> ($status)<br>";
}
}

$output .= '</div>';


<?php
$username = $_POST['username'];
$userlevel = $_POST['userlevel'];
$loggeduser = $_POST['loggeduser'];

include "database.php";

$result = mysql_db_query($dbname, "SELECT * FROM member WHERE MemberType = '5' or MemberType = '4' order by username asc ");
echo "<b>Administrators:</b><br>";
if (mysql_num_rows($result)) {
   while ($qry = mysql_fetch_array($result)) {

$query2 = mysql_query("SELECT * FROM member WHERE UserName='$qry[UserName]' ")
or die("Could not insert data because ".mysql_error());
$qry2 = mysql_fetch_array( $query2 );

$query4 = mysql_query("SELECT * FROM onlineusers WHERE UserName='$qry[UserName]' ")
or die("Could not insert data because ".mysql_error());
$qry4 = mysql_fetch_array( $query4 );

$query3 = mysql_query("SELECT * FROM room WHERE RoomID='$qry4[RoomID]' ")
or die("Could not insert data because ".mysql_error());
$qry3 = mysql_fetch_array( $query3 );

if (mysql_num_rows($query4) == 0) {
$status = "Offline";
}
else
{
$status = "$qry3[RoomName]";
}
echo "<img src=images/icons/admin.png> $qry[UserName] <a href=member.php?$qry2[MemberID]-$qry2[UserName]>[View Profile]</a> ($status)<br>";
}
}



$result = mysql_db_query($dbname, "SELECT * FROM member WHERE MemberType = '3' order by username asc ");
echo "<br><b>Senior Moderators:</b><br>";
if (mysql_num_rows($result)) {
   while ($qry = mysql_fetch_array($result)) {

$query2 = mysql_query("SELECT * FROM member WHERE UserName='$qry[UserName]' ")
or die("Could not insert data because ".mysql_error());
$qry2 = mysql_fetch_array( $query2 );

$query4 = mysql_query("SELECT * FROM onlineusers WHERE UserName='$qry[UserName]' ")
or die("Could not insert data because ".mysql_error());
$qry4 = mysql_fetch_array( $query4 );

$query3 = mysql_query("SELECT * FROM room WHERE RoomID='$qry4[RoomID]' ")
or die("Could not insert data because ".mysql_error());
$qry3 = mysql_fetch_array( $query3 );

if (mysql_num_rows($query4) == 0) {
$status = "Offline";
}
else
{
$status = "$qry3[RoomName]";
}

echo "<img src=images/icons/srmod.png> $qry[UserName] <a href=member.php?$qry2[MemberID]-$qry2[UserName]>[View Profile]</a> ($status)<br>";
}
}




$result = mysql_db_query($dbname, "SELECT * FROM member WHERE MemberType = '2' order by username asc ");
echo "<br><b>Moderators:</b><br>";
if (mysql_num_rows($result)) {
   while ($qry = mysql_fetch_array($result)) {

$query2 = mysql_query("SELECT * FROM member WHERE UserName='$qry[UserName]' ")
or die("Could not insert data because ".mysql_error());
$qry2 = mysql_fetch_array( $query2 );

$query4 = mysql_query("SELECT * FROM onlineusers WHERE UserName='$qry[UserName]' ")
or die("Could not insert data because ".mysql_error());
$qry4 = mysql_fetch_array( $query4 );

$query3 = mysql_query("SELECT * FROM room WHERE RoomID='$qry4[RoomID]' ")
or die("Could not insert data because ".mysql_error());
$qry3 = mysql_fetch_array( $query3 );

if (mysql_num_rows($query4) == 0) {
$status = "Offline";
}
else
{
$status = "$qry3[RoomName]";
}

echo "<img src=images/icons/moderator.png> $qry[UserName] <a href=member.php?$qry2[MemberID]-$qry2[UserName]>[View Profile]</a> ($status)<br>";
}
}
echo "test $username $loggeduser $userlevel";
?>

solved please delete