$ _ POST []; how can I define a message in flash and hand it over to post, and then write $ _ POST ['message'] in phph? I want to interact with actionscript in this way, however, php compilation fails. the error message is not defined.
Reply to discussion (solution)
Then you can see what has been passed in.
Paste your code
Then you can see what has been passed in.
Moderator
Have you ever touched on actionscript? this is the actionscript code I found online. I cannot understand this code. here, the message should be a member of URLVariables. And it belongs to the values object. if $ _ POST ['message'] is directly written in php, how does php know what this message is?
Var loader: URLLoader = new URLLoader (); // declare a URLRequestvar url: URLRequest = new URLRequest ("test. php "); // Set the transmission mode to POSTurl. method = URLRequestMethod. POST; // declare a URLVariablesvar values: URLVariables = new URLVariables (); // Set the information values to be transmitted. message = "hello im flash! "; Url. data = values; loader. addEventListener (Event. COMPLETE, loaded); function loaded (e: Event) {trace (loader. data);} loader. load (url );
Paste your code
This is the case with the actionscript code.
Var loader: URLLoader = new URLLoader (); // declare a URLRequestvar url: URLRequest = new URLRequest ("helloPhp. php "); // Set the transmission mode to POSTurl. method = URLRequestMethod. POST; // declare a URLVariablesvar values: URLVariables = new URLVariables (); // Set the information values to be transmitted. message = "hello im flash! "; Url. data = values; // listens to the event loader that completes data loading. addEventListener (Event. COMPLETE, loaded); function loaded (e: Event) {// output the data trace (loader. data);} loader. load (url );
Php is like this
The expected result is that "hello im php ~" is displayed in the flash output column ~ "
Php displays "hello im php ~ Hello im flash! "
The actual result is that the fourth line of php compilation is not complete, and the message is not defined.
If the fourth line is commented out, php will display "hello im php ~ "
The flash output column displays all the text in the php file instead of "hello im php ~ "
The text of the entire php file is displayed.
What does this mean?
The text of the entire php file is displayed.
What does this mean?
This looks like:
Isn't your flash loaded from the website?
Var url: URLRequest = new URLRequest ("helloPhp. php ");
Should be
Var url: URLRequest = new URLRequest ("http: // localhost/helloPhp. php ");
Isn't your flash loaded from the website?
Var url: URLRequest = new URLRequest ("helloPhp. php ");
Should be
Var url: URLRequest = new URLRequest ("http: // localhost/helloPhp. php ");
It turns out that php has completed passing values to the event code, but how can I get the message sent from the as to php.
Echo $ _ POST ['message'];
No?
So what?
Echo file_gey_contents ('php: // input ');
Isn't your flash loaded from the website?
Var url: URLRequest = new URLRequest ("helloPhp. php ");
Should be
Var url: URLRequest = new URLRequest ("http: // localhost/helloPhp. php ");
It turns out that php has completed passing values to the event code, but how can I get the message sent from the as to php.
It indicates that the file_gey_contents () function is not defined. Flash receives echo output data, but if you want to dynamically obtain different data in php, how can you refresh echo output?
File_geT_ Contents
Echo $ _ POST ['message'];
No?
So what?
Echo file_gey_contents ('php: // input ');
The reference on the 10th floor is wrong. if it doesn't arrive at you, I will test echo $ _ POST ['message'] in fla. the call is successful, but if it is published to swf, it will not work well, compiling php with apache is not acceptable. You can use it in fla. Thank you very much! Finally finished!