Exporting data with flash

I´m a flash newby so this might be a boring question…

How do I store data (ie username and email from a form)?

I would like to store the values of variables in a simple textfile.
Is this possible in flash or do you have to send the data to a database.

Also what would be the best database to use to store simple information as in the example above.

Any input would be apreciated
Cheers

well, what tool to use is all a matter of preference:

to get data into flash from other files, you will use the LoadVars() object, you can do this in a text file, and the object get all the variables, or you get the information from a database using some server language.

if you’d like some example just ask.

Also what would be the best database to use to store simple information as in the example above.

Hey cucaracha,

Well, MySql is much handy, but text-files are much easier!

yours,
h88

Thanks for the quick reply guys,

But what I really want is save (export) data from flash into a file.
Ie Have a visitor on my page put in his name and email address through a form, and then store this information in a text - file.

would u like to have something like users email u thier address and names?

yours,
h88

PS. You Should have in both cases PHP Enabled Host!

:-\

No, I want users to fill in a form on my webpage, and store this info in a file.

Anyway I´m getting the feeling this is not done in Flash and probably needs to be done in javascript or php or something.

un saludo

well, you have to use a server language, using a database it’s much more easy to do, but you can do with text files too, but the final result isn’t soo good, because, in text files will become too complex to keep track of all the variables, a thing that’s much easy to do in PHP, but if you want just to show the results of the entries, the text file will be enough, but all the content will be with none organization, i was doing some here in a hurry and i did something like insert a name, next line the email, two lines then the repreat of this insertion process, it’s was ok, you can then do something in php to read all the file and put this in a dinamic text field to users can read.
if you’d like something like this, tell me and i explain you how to do this.

Hi thanks all for your replies.

I think I will go for the database option, but I really would like to know how to do it through a text file, just for the learning process.

well to do this in a text file try something like this:

in the submit buttom in flash:

on(release){
obj_save = new LoadVars();
obj_resp = new LoadVars();
obj_save.s_name = t_name.text;
obj_save.s_email = t_email.text;
obj_save.sendAndLoad(“texto.php”, obj_resp, “post”);
obj_resp.onLoad = function(){
reply.text = "Thanks! Your name is " + t_name.text + ". And your email is " + t_email.text + “!”;
}
}
in this script you crate 2 objects, 1 to connect to php and 1 to receive the replyes after the insertion is ok, i think there’s no secret here, if you don’t understand the script just ask and i explain you well.

and the php file:

<?php
$open_file = fopen(“data.txt”, “a”);
fwrite($open_file, “Name:”.$s_name."
E-mail:".$s_email."
");
fclose($open_file);
?>
here you just open a file (“data.txt”) with the option to append (“a”) in a file, if you put “w” it will overwrite the current text.
then you write in the text file the properties of the object of the connection, wich will automatically become variables of the same name in php, the last line you just close the file to don’t worry abount nothing. of course, this code can be veryt more consistent, but i just give the first step, it’s up to you finish it better, but this works good, but not so good.

any doubts, just ask.

Gonna try that out as soon as I get home

Obrigado!