View Full Version : Flash to PHP to Mysql & Back Again

08-25-2009, 02:13 AM
I need some help getting my Flash based form to MySQL database. I can get the fields necessary from Flash to PHP, (as I normally send an email with this data) and I have figured out how to parse the (manually created) database as XML back to Flash.
I am just stuck in the middle.
Please help, as this project is nearing deadline.
I can post examples if necessary.


08-25-2009, 07:20 PM
Hey there...

I'm not quite sure of your problem...are you having trouble using flash to call a PHP script?

or are you having trouble using PHP to send back to a flash script?

Are you using AS2 or AS3?


08-26-2009, 12:09 AM
I am having trouble using PHP that is taking data from my swf and send it to MySQL database. The database is already set up and I can create fields etc. manually using phpMyAdmin.
I have successfully connected to the database with the PHP. I just need a shove in the right direction (a good example or two always helps me get to where I am going.)

08-26-2009, 10:10 AM
I am having trouble using PHP that is taking data from my swf

my first quote! w00t!

The PHP doesn't take data from the swf on its own. You need your swf to call the PHP script and send GET variables to it. Then use your PHP script to use those GET variables:


and do whatever needs to be done with that information.

Good luck and sorry if I'm not too clear :eek:


08-26-2009, 10:29 AM
thanks for sharing!

I think I may be the one who is not clear.
I can get the data from my swf using the PHP.
I have successfully set up a swf/PHP email form.
Also have success setting up a login form.
Maybe just need to modify that to get what I need.

Here is what is going on.
I have this swf... http://gnfl.net/archive/08/picks.html
This is a weekly event.
I have multiple users logging in.
Their selections get emailed to them and admin (myself).
From there, I have to enter their selections manually in spreadsheet for calculation.
I want each users input (selections) to go to the database, where I can then successfully parse the XML to Excel and do the calcs automatically.
I got the last part (MySQL to XML) to work using gotoAndLearn (http://www.gotoandlearn.com/) tutorial.

08-27-2009, 10:45 AM
Hi again...

Sorry I must be missing something...I still can't see what your problem is. What bit is not working?

Maybe just need to modify that to get what I need.

Don't you already have what you need?


08-27-2009, 10:06 PM
Let me try to explain better.
How do I get my data from Flash to mySQL data tables?
From there I can get it back as XML.
I just am having trouble getting it to my DB.
Can you lead me to a specific example that will help?

08-27-2009, 10:13 PM
Hi again...

Heres a tutorial for using PHP with Mysql databases:


Hopefully this should get you going.

The steps to get Flash to write info to a db are the following:

1. Swf sends data to PHP script.
2. PHP script receives data sent from flash.
3. PHP writes received data to a database.

I hope the above stuff is relevant to your problem :eek:

Sorry if I haven't been clear and the very best of luck! :cool:


10-30-2009, 08:58 AM
Take the text box contents that you e-mailed:

var strURIArr1Variable:String = "";
var strHomeVariable:String = "http://localhost/"; // your website

strURIArr1Variable = strHomeVariable + "testapps/app01.php?" + _global.strReqVariable + "=" + _global.strValVariable;

Set your _global.strReqVariable to "email" and _global.strValVariable to the text box that was used for e-mail.

You can add a "&" between each value. Like: email=[email protected]&sent=11/01/2009

In your PHP file, you get the Request Variables from the URL and save them to MySQL. That's one way to do it.

myVars = new LoadVars();
myVars.load(strURIArr1Variable, this, "GET");

The second part is to get that data back from MySQL and show it in flash? Use LoadVars(). Tutorials for LoadVars() are around here somewhere, or check the Help file in Flash for info on this function.

There's more to this, but that should get you started.

01-01-2010, 05:40 PM
I have a contact form on my website which is embeded into the.swf
Currently that form isn't setup to work. I have a working contact form

PHP Code below
<?php session_start() ?>
include "db_registrations.php";
// defaults
$name = "";
$email = "";
$city = "";
$comments= "";
$regtime= "";

$name = substr(trim(strip_tags($_POST['name'])), 0, 100);
$email = substr(trim(strip_tags($_POST['email'])), 0, 100);
$city = substr(trim(strip_tags($_POST['city'])), 0, 100);
$comments = substr(trim(strip_tags($_POST['comments'])), 0, 1000);
$regtime = time();
$tdisplay = date("F j Y h:i", $regtime);
//CAPTHCA is valid; proceed the message: save to database, send by e-mail ...

$query = "insert into contacts (name, email, city, comments, regtime) values ('$name', '$email', '$city', '$comments', '$regtime')";
$result = mysql_query($query) or die("Error: Query failed.<br /><br />$query<br /><br />" . mysql_error());

// mail to jean vallery
$to = "[email protected]";
$subject = 'Contact Form Submitted (contactmedirectly.php)';
$message = '
PHP code above

I would like to know how to write the ac 2.0 script to complete this process.
the form that isn't active is located at , in the menu mouseover contact

I don't want to reinvent the wheel but learn how to write the AC script

04-20-2010, 12:59 PM
You need to know php and mysql. Try to use php tutorials (http://phpforms.net/tutorial/tutorial.html).