Log in

View Full Version : How to make Flash works with PHP to create TXT file?



benazio
06-08-2009, 11:56 AM
so here goes,

the point is, i have created an order form in flash cs3 with actionscript 3.0, and my lecture wants my flash to be working with PHP, so if i click the submit button, my flash will load the PHP file and created a .TXT file in the directory(offline) which includes the information of the order form!

i've already research for this problem, but all i got is a script to send email from a form! i need something that can be working offline to show it to my lecture..

maybe the php script would be something like this example,


<?php
$File = "YourFile.txt";
$Handle = fopen($File, 'w');
$Data = "Jane Doe\n";
fwrite($Handle, $Data);
$Data = "Bilbo Jones\n";
fwrite($Handle, $Data);
print "Data Written";
fclose($Handle);
?>

but i still need help from the master please! :confused: thanks!! i have to collect it tomorrow (GMT+7!) !! :worship:

Medyman
06-09-2009, 01:24 PM
First, people on this forum are not in the business of doing other's homework assignments. Perhaps, you should seek the advice of someone in your department for more tangible help than what I'll be giving.

This really is two different operations. The first his the AS. The second is the PHP. There needs to be a AS bridge between the Flash app and the PHP script.

The first thing you should do is write a PHP script that can write/edit a plain text file. You might be interested in this (http://www.tizag.com/phpT/filewrite.php), this (http://www.swish-db.com/tutorials/view.php/tid/343) or this (http://www.dynamicdrive.com/forums/showthread.php?t=19370).

Once you have that, replace the hardcoded values with variable names. Those variable names should correspond to the field names in your Flash app.

Next, POST the values from Flash to the PHP. Some of the tutorials at gotoandlearn() should be of help (e.g. this (http://gotoandlearn.com/play?id=20) and this (http://gotoandlearn.com/play?id=78)).

Finally, you'll need PHP to be able to demo this. That means you'll need a LAMP server of some sort - if you don't have something installed on your computer (WAMP, MAMP, XAMPP, etc..), you'll need to upload this online.