# AS3 load php variable in text field

**URL:** <https://forum.kirupa.com/t/as3-load-php-variable-in-text-field/317147>\
**Category:** flash\
**Created:** [December 11, 2010, 10:58pm UTC](https://forum.kirupa.com/t/as3-load-php-variable-in-text-field/317147 "2010-12-11T22:58:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dinho](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@dinho](https://forum.kirupa.com/u/dinho)\
**Post date:** [December 11, 2010, 10:58pm UTC](https://forum.kirupa.com/t/as3-load-php-variable-in-text-field/317147/1 "2010-12-11T22:58:12Z")

</div>

Hello everybody.  
I’m trying to make the day flash send the variables to a text field with as3.

AS3  
//----------------------------------------------//

import flash.events.MouseEvent;  
import flash.net.URLLoader;  
import flash.net.URLRequest;  
import flash.net.URLLoaderDataFormat;  
import flash.events.Event;

btn.addEventListener(MouseEvent.CLICK, klik);  
function klik(e:MouseEvent):void{  
var req:URLRequest = new URLRequest(“file.php”);  
var loader:URLLoader = new URLLoader(req);  
loader.dataFormat = URLLoaderDataFormat.VARIABLES;  
loader.addEventListener(Event.COMPLETE, carregou);  
}

function carregou(e:Event):void{  
trace( e.target.data.username);  
}

//----------------------------------------------

PHP  
//----------------------------------------------

\<?php

if (!$\_POST[“username”]||$\_POST[“username”]==“Mail”) $username=“Mail”.rand(100,99999);

else $username=$\_POST[“username”];  
$username=preg\_replace("/[^0-9a-zA-Z]/","-",$username);  
setcookie(“username”,urlencode($username),time()+36000);  
?\>

//----------------------------------------------

but the following error appears:

Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs  
at Error$/throwError()  
at [flash.net](http://flash.net)::URLVariables/decode()  
at [flash.net](http://flash.net)::URLVariables()  
at [flash.net](http://flash.net)::URLLoader/onComplete()

just need the username variable in the flash is received and displayed in text field.

would appreciate if someone could help me.  
Thank you all.
