PDA

View Full Version : flash.exe forms


jansue
02-19-2008, 09:59 PM
Is it possible to create a form in flash and publish it as an .exe sending the information to a php processing form and then sending the form information into a database using PHP? If I create a form and use a php processing form it works in flash.swf but not if I create the form and publish it as a .exe. Is there any way to do this?

CyanBlue
02-20-2008, 01:07 PM
Howdy and Welcome... :)

I don't see why it would not work... Um, the only reason I can think of is when Flash is not able to find the PHP file when calling it... You need to use an absolute path to the PHP file if you call it from the projector...

jansue
02-20-2008, 03:48 PM
It doesn't seem to find the php file. It adds a lot of garbage when it's looking for the path.

CyanBlue
02-20-2008, 03:51 PM
What is the code you are using and what kind of garbage are you talking about??? Can you show me that???

jansue
02-20-2008, 06:37 PM
_http://www.xxx/testing_folder/opp_reg/process.php?id=%3Cp+align%3D%22left%22%3E%3C%2Fp%3 E&name=ssss

I guess I have to pass the variables instead of just accessing a php form.
My form name is process.php

CyanBlue
02-20-2008, 07:18 PM
Um... You don't really think that'll help me understand what sort of code you have in your file, do you???

northcode
02-20-2008, 07:44 PM
This overrides the LoadVars object so you can retrieve the results of your post (assuming your PHP script returns something you can use).


LoadVars.prototype.decode = function(str)
{
this.$pureloadvars = str;
var path = this.$pureloadvars;
path = path.split("&");

for (var i = 0; i<path.length; i++)
{
path[i] = path[i].split("=");
this[path[i][0]] = {};
this[path[i][0]] = path[i][1];
}
};


Once the prototype is defined you can use this code to post data to your PHP script and get the results back (see the trace statement in the onLoaded function).

send = new LoadVars();
recv = new LoadVars();
recv.onLoad = onLoaded;

function onLoaded()
{
trace(recv.$pureloadvars);
}

send.id = '<p align="left"></p>'
send.name = 'ssss';

send.sendAndLoad("http://www.whatever.com/process.php", recv, "POST");

jansue
02-20-2008, 07:45 PM
It's just a form with a varible in the input field and this code on the submit button.
on (release) {
getURL("http://webaddrdess/testing_folder/opp_reg/process.php", "", "GET");
}

jansue
02-20-2008, 07:55 PM
I just need it to enter the data in the database from a flash form. The php form works from regular html form. Northcode, is this what the code you listed does?

CyanBlue
02-20-2008, 07:58 PM
Try this then...
on (release) {
var _lv:LoadVars = new LoadVars();
_lv.id = variableThatHoldsIDData;
_lv.name = variableThatHoldsNameData;
_lv.send("http://www.domain.com/process.php");
}
If that does not work, I doubt why that won't work, you need a third party projector to do so, where northcode can help you better in that field... ;)

northcode
02-20-2008, 11:55 PM
The code I posted will work in a browser, from a Flash EXE and from any third party projector that doesn't cause more problems than it solves (no names :)) It's a more advanced version of the example CyanBlue has posted because you can get feedback from the PHP script about whether the data was submitted successfully or not (if the PHP script generates output you can use).

CyanBlue
02-21-2008, 01:23 PM
Haha... I somehow read the decode() function, but totally missed the other scripts, northcode... If I had read more carefully, I would not have written what I have written... :D

What is the $pureloadvars bit??? Is there any special meaning to it or is it just a generic way of specifying a variable from PHP???

northcode
02-21-2008, 05:31 PM
Using a $ in a variable name in Flash is supposed to hide it from enumeration (like private data). I didn't write the original prototype, but I have used it extensively because it's a brilliant little trick. You can use it to retrieve an HTML page (or the resource at any URI) and do whatever you want with it. Screen scraping, web services, whatever you like.

CyanBlue
02-21-2008, 06:22 PM
That's interesting... Thanks for the info... ;)

jansue
02-27-2008, 01:53 PM
send.id = '<p align="left"></p>'
send.name = 'ssss';

The variable in the form are id and name. The copy after the = make it into the database but if I type something in the form it doesn't work. What am I doing wrong?

northcode
02-27-2008, 03:50 PM
The code on the server side that puts the field values in the database appears to be brain damaged. It should be escaping whatever you send it. If the contents are being mangled the it's obviously not doing that. You need to fix the code that does the insert.

jansue
02-27-2008, 05:24 PM
(I'm really new at this stuff so...)

I have text input fields and have the variables for the input fields id and name. Is there anything else I have to do. I thougt that the input text would be sent to the variable. I have all the code in the submit button. Any suggestions?


Should it just be like this

send.id
send.name

or like this???

send.id = id
send.name = name

northcode
02-27-2008, 08:34 PM
The variables are being sent ok, I'm guessing that the problem is with the server side script that you're using to process the that Flash is sending. Normally you can't just pass any old data to your database, you have to massage it a bit before you just jam it into a SQL insert statement.

jansue
02-28-2008, 03:41 PM
The copy IS making it into the database. The problem is the copy in quotes is making it to the database not the text that is entered in the input field. The type that is entered is in quotes.

send.id = 'this copy goes to database'
send.name = 'this copy goes to database';

How do I make the copy that is entered in the input field go into the database? The name of the input field is id and name but the only copy that goes into the database is the copy in the single quote however.

northcode
02-28-2008, 04:31 PM
Use something like this...

send.id = field1_text.text;
send.name = field2_text.text;

Where field1_text and field2_text are the names of the text fields in your Flash form.

jansue
02-28-2008, 06:02 PM
That's it...it works. I thought I tried that but maybe I didn't put the .text. Thanks so much!!!!!