Solved

Using Flash to Submit to PHP

Posted on 2008-09-29
5
233 Views
Last Modified: 2013-11-11
I am trying to use a flash form to submit to a PHP script.

I've followed a simple tutorial where I add a text box and a button.

The text box is set to Input Text and on the button I have the following script:

on(release) {
      getURL('test.php', '', 'POST');
}

All seems to be working except that when I do a print_r($_POST); I get the following:

Array
(
    [q] => <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Arial\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">fdsafdsafdsa</FONT></P></TEXTFORMAT>
)

Is there any way to get the data that is in the flash var without all this other crap or must I now parse this with php to get the value that I'm looking for?
0
Comment
Question by:Hube02
  • 3
  • 2
5 Comments
 
LVL 37

Assisted Solution

by:CyanBlue
CyanBlue earned 250 total points
ID: 22598698
getURL() function automatically passes all the variables in its scope...  
You should really use LoadVars.sendAndLoad() function and specify what you want to pass...

So, it'd be something like this...

CyanBlue
var _lv:LoadVars = new LoadVars();
_lv.variableToSend = someTextField.text;
_lv.sendAndLoad("test.php", _lv, "POST");
_lv.onLoad = function (ok) {}

Open in new window

0
 
LVL 18

Author Comment

by:Hube02
ID: 22598788
Changing my line with getURL() to the above appears to do nothing at all.

I need this to work just like a normal form with the action of "test.php" an the method of "post" where the broswer goes to that URL and that url process the from and then displays some output.

As I said, I'm following the tutorials I've found and they all use the getURL() function and none of them say anything about getting past an XML string of junk.
0
 
LVL 18

Author Comment

by:Hube02
ID: 22599327
Well, this is what I did...

The instance name of my text field is "SearchTerm"

I changed my script to the following:

on(release) {
      var q:String = SearchTerm.text;
      getURL('test.php', '', 'POST');
}

Other than this everything else is the same as ALL the tutorials that I've found. You'd think that they would not miss this simple step in a tutorial or to at least tell you in the tutorial that what you really get is all the formatting of a text field if you don't do something to change it.

My question is, why would they think we'd want all that crap to begin with?

Anyway, problem solved
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 22612774
It probably is the case where the tutorials are dealing with the regular textField but you are dealing with the HTML enabled textField...

At any rate, the purpose of the tutorial is that you learn specific item in a quick manner...  You should not rely on those because there are many that are written poorly...  I'd stick with the Flash manual to learn the specific stuff...  I've got to admit that Flash manual is not the most intuitive material you can study, but it's got vast information that's viable to survive in this AS world...  ;)

At any rate, glad to hear that you've got it sorted out...  ;)

CyanBlue
0
 
LVL 18

Accepted Solution

by:
Hube02 earned 0 total points
ID: 22613297
Thanks for the info. As you can guess, I'm not a flash person. This project just got dumped on me. I was given a flash file that was supposed to have two forms in it, one for a search and another simple contact form, and told "Make it work." Always fun, an annoying...
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question