POST variables from external source (Flash)

Hi,

I’m having trouble with a script of mine which should work, but doesn’t for a reason that escapes me. I’m using a sendAndLoad function within Flash to, well, send and load variables to a .php file using POST. The problem is that it works, but only once. Basically, I’m trying to create a user login page within Flash, and I want the user to be able to try logging in multiple times: the first time, the script works, but if the user fails to authenticate the first time and tries again, the script fails to work properly again.

Server-side script:

if ($_POST['data']=="login") {
    $query = "SELECT * FROM Members WHERE Name='" . $_POST['name'] . "'";
    $answer = mysql_query($query);
    if ($row = mysql_fetch_array($answer)) {
        $team = $row['Team'];
        $name = $row['Name'];
        $pass = $row['Password'];
        if ($_POST['pass'] == $pass) {
            echo "&result=success";
        } else if ($_POST['pass'] != $pass) {
            echo "&result=passfail";
        }
    } else {
        echo "&result=userfail";
    }
}

As far as I’m concerned, I’m simply a bit ignorant about the way PHP sends and receives information via POST. So what am I forgetting about?

Thanks!