Skip to main content
July 24, 2013
Question

AS3: How to restrict urlvariables to send variables with POST method?

  • July 24, 2013
  • 2 replies
  • 612 views

Hi Everyone,

I am struggling with urlvariables of AS3, they are sending variables with GET method while i am using POST method, Please help,

Here is my code:

----

AS3

----

req = new URLRequest(url);

user_lead = new URLVariables();

vars['email'] = "test@test.com";

vars['content']= "dummy Contents here";

req.data = vars;               

req.method = URLRequestMethod.POST;               

ldr = new URLLoader();

ldr.dataFormat = URLLoaderDataFormat.TEXT;

//ldr.dataFormat = URLLoaderDataFormat.VARIABLES;

ldr.addEventListener(Event.COMPLETE, checkResponse);

ldr.addEventListener(IOErrorEvent.IO_ERROR, IOErrorHandler);

ldr.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);               

ldr.load(req);

navigateToURL(req);

-----

PHP:

-----

<?php

   

    echo $_POST["email"];      //NOT WORKING

    //echo $_REQUEST["email"];  working fine

    //echo $_GET["email"];  working fine

   

?>

Thanks,

Maani

This topic has been closed for replies.

2 replies

sinious
Legend
July 24, 2013

You should be using the var "user_lead" to set your vars and pass that to the .data property.

e.g.

var req:URLRequest = new URLRequest(url);

var user_lead:URLVariables = new URLVariables();

user_lead.email = "test@test.com";

user_lead.content = "dummy Contents here";

req.data = user_lead;              

req.method = URLRequestMethod.POST;              

ldr:URLLoader = new URLLoader();

ldr.dataFormat = URLLoaderDataFormat.VARIABLES;

ldr.addEventListener(Event.COMPLETE, checkResponse);

ldr.addEventListener(IOErrorEvent.IO_ERROR, IOErrorHandler);

ldr.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);              

ldr.load(req);

kglad
Community Expert
Community Expert
July 24, 2013

1. remove that navigateToURL

2. what is vars?

3. what's the purpose of user_lead?