strange problem with FLASH / PHP

advertisements

i am having strange issue with Flash and PHP. actually i have one Forgot password form in flash in which user enters his email id and when presses submit button flash passes data to PHP and retrieves(here i am stuck) data from PHP.

The issue is Flash getting UNDEFINED from PHP.

my flash code.

var email_id:RegExp = /(\w|[_.\-])[email protected]((\w|-)+\.)+\w{2,4}+/;
var urlRequest:URLRequest = new URLRequest("forgot_password.php");
var urlVariable:URLVariables = new URLVariables();

var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

urlLoader.addEventListener(Event.COMPLETE, urlLoader_complete);

btn_submit.addEventListener(MouseEvent.CLICK, btn_submit_click);
function btn_submit_click(e:Event)
{
    if(txt_email.text == "")
    {
        txt_error.text = "Email can not be blank.";
    }
    else if(!email_id.test(txt_email.text))
    {
        txt_error.text = "Enter proper email address.";
    }
    else
    {
        urlVariable.mailId = txt_email.text;
        urlRequest.data = urlVariable;

        urlLoader.load(urlRequest);
    }
}

function urlLoader_complete(e:Event)
{
        trace(e.target.data.return_var); // **it receive Undefined** i am checking in flashlog.txt :(
    //txt_error.text = e.target.data.return_var;
}

my PHP code

<?php
require_once('connection.php');

$query = "select * from user_account where email='".$_REQUEST['mailId']."'";
$result = mysql_query($query);

if(mysql_num_rows($result) > 0)
{
    echo "return_var=success";
}
else
{
    echo "return_var=failed";
}
 ?>

there is a space before return_var but i don't know why.. i have checked my PHP file 100 times it is perfect than what is the issue??????????????????????????????????????????

EDIT:

If i am tracing

    trace(e.target.data);

it traces
   %20return%5Fvar=success

Note %20 before return%5var // what is that?????????????


Obviously problem isn't in PHP, anyway you should write it something like this to prevent SQL injection...

<?php
require_once 'connection.php';

$email = $_GET['mailId'];
$email = mysql_real_escape_string($email);

$query = "SELECT email FROM user_account WHERE email = '$email' LIMIT 1";
$result = mysql_query($query);

echo (mysql_num_rows($result) > 0)? 'return_var=success': 'return_var=failed';
?>