tags:

views:

72

answers:

1

Hi,

I have a file that takes a variable from the user then prints something, let say

$something = $_GET['something'];
echo $something;

It works perfectly fine with GET, however, if you change this to post it stops working. I am sending the request from a flex client to the PHP code, and I am using a get request when I am using get in php and a post request from flex when I am using a post request in PHP. Is there a way to know why POST is not working?

The post request I used from flex:

var variables:URLVariables = new URLVariables("username=" + username + "&password=" + password);
var request:URLRequest = new URLRequest();
request.url = proxy + "authenticate.php";
request.method = URLRequestMethod.POST;
request.data = variables;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, authenticateUserHandler);
try {
loader.load(request);
}
catch (error:Error) {
Alert.show("Unable to load URL");
}

(Note, I use the same thing for GET except I change the .POST to .GET)

Please feel free to ask me for any additional details or information.

+2  A: 

It's strange, UrlRequest should work fine with POST, i know that you can't pass variables if you also send binary data but it's not your case.

Anyway, try to rethink the problem using HttpService (much cleaner than URlRequest IMHO). In your case something like this should do the work:

var params:Object = {};
params.username = _view.username.text;
params.password = _view.password.text;

var service:HTTPService = new HTTPService();
service.url = proxy + "authenticate.php";
service.method = "POST";
service.addEventListener("result", authenticateUserHandler);
service.send(params);

Hope this help

wezzy