# External .txt

**URL:** https://forum.kirupa.com/t/external-txt/252
**Category:** flash
**Created:** [July 11, 2002, 6:28am UTC](https://forum.kirupa.com/t/external-txt/252 "2002-07-11T06:28:39Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![bcogswell11](https://avatars.discourse-cdn.com/v4/letter/b/8e7dd6/32.png) [@bcogswell11](https://forum.kirupa.com/u/bcogswell11)
#### Post date: [July 11, 2002, 6:28am UTC](https://forum.kirupa.com/t/external-txt/252/1 "2002-07-11T06:28:39Z")

</div>

Hey guys.  
I saw this tutorial on [Flashkit.com](http://Flashkit.com) and I have a couple of questions:

[The tutorial](http://www.flashkit.com/tutorials/Dynamic_Content/Creating-Rafael_F-15/index.shtml)

All I want to do is have an a form where users can input their email address and then the email address will be stored in a .txt file in my directory. My question is at the end the tutorial gives some lines of code that looks like this:

On (Release)  
Load Variables (“[http://www.server.com/cgi-bin/myform.cgi](http://www.server.com/cgi-bin/myform.cgi)”, 1, vars=POST)  
End On

I have no experience with cgi, so is all I do save a .txt file as .cgi and name it myform, and then place it in my directory. And then I replace [server.com](http://server.com) with the address of my site?

Thanks guys!  
-brad-

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2002, 12:55pm UTC](https://forum.kirupa.com/t/external-txt/252/2 "2002-07-11T12:55:39Z")

</div>

not quite. Your flash movie is sending its variables to the cgi script. The cgi script is actually going to write to the text file.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2002, 8:28pm UTC](https://forum.kirupa.com/t/external-txt/252/3 "2002-07-11T20:28:14Z")

</div>

I don’t have a .cgi file or anything in my directory. So is the file going to automatically make a .txt file and start adding the addresses? Also, is there a way to do this without cgi? Can I just have the variable sent to a .txt file in my directory?

Thanks  
-brad-

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2002, 8:37pm UTC](https://forum.kirupa.com/t/external-txt/252/4 "2002-07-11T20:37:04Z")

</div>

A cgi or php file is needed to communicated between the text and flash file. Strange that the cgi file isn’t included for download on this tutorial.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 11, 2002, 9:49pm UTC](https://forum.kirupa.com/t/external-txt/252/5 "2002-07-11T21:49:47Z")

</div>

Hmmm…Do you know of another tutorial where I could get the file?

Thanks!  
-brad-

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 13, 2002, 1:30am UTC](https://forum.kirupa.com/t/external-txt/252/6 "2002-07-13T01:30:33Z")

</div>

I’m still looking for a tutorial on how to store vairables in a .txt file. I am just trying to move this post up.

Thanks!  
-brad-

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 14, 2002, 7:51pm UTC](https://forum.kirupa.com/t/external-txt/252/7 "2002-07-14T19:51:12Z")

</div>

Hello bcogswell11,

do you have access to PHP on your server? It’s quite easy to write to a file or create a new file using PHP. If you do have access to it, let me know and we can discuss the details.

🙂  
-ptolemy

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2002, 3:32am UTC](https://forum.kirupa.com/t/external-txt/252/8 "2002-07-15T03:32:10Z")

</div>

Yes I do have PHP access. Thanks for your help. I have looked all over the internet and I can’t find what I need. All I want is an input box that stores a variable in an outside file. In this case, the variable will be email addresses. This way, I can go to the outside file and just have the long list of addresses that I can move to my E-mail.

Thanks!  
-brad-

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2002, 4:36am UTC](https://forum.kirupa.com/t/external-txt/252/9 "2002-07-15T04:36:35Z")

</div>

**Part 1: Sending vars from Flash to PHP**

To do this you need to create a dynamic text box and give it a variable name (not an instance name!). Name it something like _e-mail_. Now, create some sort of submit button and attach the following code to it (assuming you’re using MX):

```auto

on(release) {
  dataContainer = new LoadVars();
  dataContainer.email = email;
  dataContainer.send("http://path/to/host/write.php", "sendWindow", "POST");
}

```

**Part 2: Writing Flash vars to file with PHP**

Create a new PHP file named _write.php_ and insert the following code:

```php

<?php
  $file = "path/to/file/to/write/to";
  $handle = fopen($file, "a");
  fwrite($handle, "
$_GET[email]");
  fclose($handle);
?>

```

\*If _$\_GET_ isn’t working for you, don’t fret. Use $HTTP\_POST\_VARS[email] instead.

As you can see, it’s quite a simple process. I had problems when I tried this on my host. They told me fwrite() wasn’t permitted. If this is the same with your host, simply add a shebang line to the path of php on the host and you will probably be able to access fwrite(). I can’t guarantee that it will work but I know it did for me.

Let me know how things turn out.

🙂

-ptolemy

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2002, 5:30am UTC](https://forum.kirupa.com/t/external-txt/252/10 "2002-07-15T05:30:15Z")

</div>

As I am doing this I am trying to understand the process as well. In write.php I am telling Flash to store the variable in the .txt file right?

Other than that I understand the whole thing. My site will be up tomorrow night and I will see if it works and let you know. Thank you for your help!

Thanks!  
-brad-

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2002, 12:03pm UTC](https://forum.kirupa.com/t/external-txt/252/11 "2002-07-15T12:03:00Z")

</div>

Actually Flash has no part in thr writing process. It is simply defining the value of the email address that will be written to a file by the PHP script. Flash just passes that value to the write.php file. If Flash could write to files, there would be no need for PHP in this case.

-ptolemy
