Solved

Using Flash to Submit to PHP

Posted on 2008-09-29
5
231 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now