Note that there are some explanatory texts on larger screens.

plurals
  1. POHTTP Post fields are not received by PHP script
    text
    copied!<p>I feel stupid asking this question, but I've been wrestling with it for hours and I don't know where else to turn. </p> <p>I have a flash form that is making a POST request to a php script, and then displays the output of the said script. For the sake of simplicity, let's say this is the php script:</p> <pre><code>echo 'Mail sent to: ' . $_POST['recipientEmail']; </code></pre> <p>When I submit the form, I see this in Firebug's net tab in the line made by the POST request:</p> <pre><code>Referer: http://example.com/my.swf Content-type: text/html Content-length: 68 recipientEmail=example@example.com </code></pre> <p>All well and good on the surface. The post has been made, it sent the right variable to the script. But when the response comes back, this is what I see in my Flash tracer:</p> <pre><code>Mail sent to: </code></pre> <p>In other words, the $_POST['recipientEmail'] has been lost after the request went out of my browser. </p> <p>What do you think is happening here? Both the script and the swf file are in the same domain, same server.</p> <p>EDIT: I just tried hitting the same script from an HTML form, and it catches the $_POST header. So it's only not catching it when it's sent by Flash. The post tab in Firebug looks a little different than it is with flash:</p> <pre><code>recipientEmail example@example.com submit Submit </code></pre> <p>Notice each variable is in its own line.</p> <p>EDIT: Here is the relevant AS3 code that makes the submission:</p> <pre><code> var _gateway:String = Share.getGateway(); var request:URLRequest; var variables:URLVariables = new URLVariables(); var loader:URLLoader = new URLLoader(); request = new URLRequest(_gateway); request.contentType = 'text/html'; request.method = URLRequestMethod.POST; variables.senderName = senderName.text; variables.recipientEmail = recipientEmail.text; variables.senderMessage = senderMessage.text; request.data = variables; try { loader.load(request); }catch (error:Error) { Debug.trace("Unable to load requested document."); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload