Why isnt this working? plz help!

Ok heres the thing…im trying to make a registering thing on flash so users can register their username and password. to do this i hafta make sure that no two users have the same username so i run a php script in which i send a flash variable of the username the user chose to the script which checks my MySQL database to make sure that the name has not been chosen and returns a variable stating whether the username is available or not. thats my problem…i cant get it to do that =(… im new both to php and flash but i think im doing anything right (then again it could be an amatuer mistake on my part). the following is my php code and the actionscript used in my flash file. plz help!

 
<?php
 
 
$username="user";
 
$password="pass";
 
$database="db_name";
 
$user=$_POST['userAval'];
 
mysql_connect(localhost,$username,$password);
 
@mysql_select_db($database) or die( "Unable to select database");
 
$query = "SELECT username FROM users WHERE username = ".$user;
 
$temp = mysql_query($query);
 
$row = mysql_fetch_array($temp);
 
if ($row['username'] == "")
 
$aval = "NOT AVAILABLE";
 
else 
 
$aval = "AVAILABLE";
 
mysql_close();
 
$rstring = "aval=".$aval;
[left]echo [/left]
$rstring;
 
?> 

this is a simplified version of my actionscript code:


on (click) {
 envelope = new LoadVars();
 envelope.userAval = box1.text;
 envelope.sendAndLoad("user.php", envelope, "POST");
 box2.text = envelope.aval;
}

[LEFT]if all goes well it should display the contents of aval in the dynamic text box, box2, but its not =( instead the text box is simply blank…help![/LEFT]