Creating Flash site, need simple mailing list sign up using PHP/MySQL DB

Posted on 2004-09-10
Last Modified: 2010-04-03
Hi, I want to create a simple mailing list signup form for my site (which will be entirely in flash) similar to the one here: accept without the zip option.

I have access to MySQL using phpMyAdmin. I was thinking that I could just store the adresses to the db. Problem is, I don't know how to do it in flash mx. I am a novice when it comes to flash, and I'm sure I'll have many questions for you. I also have several other questions about the site in general that need to be answered if anyone is interested in investigating them.

So, Problem: need functional mailing list in MX.
1) How do I integrate the form and PHP into MX so that PHP sends the addresses to the db?
2) What's the easiest way to setup the db (I don't know that either)?
3) Once the db has the addresses stored, how can I retrieve them and send out my mailer?
4) I also have Mojo Mail on my server; is there a way that I can use it to collect the names from the db and send them?

I really need answers as soon as possible.

Remember, I don't know what I'm doing, please try to simplify your explainations.

If anyone knows of any relevant tutorials, please post them as well.

Thanks very much for any help.
Question by:imawake
  • 2
  • 2

Author Comment

ID: 12034916

Accepted Solution

mrdilliard earned 500 total points
ID: 12034979
There's actually two parts to this, since Flash doesn't support direct database access without a component.

I would go ahead and create your database, and then your php page first.

I made a table in my database called MailingList, with 3 fields.
1. MailID of type INT that's an auto-incrementing field/primary key
2. Address of type VARCHAR, length 50
3. Name of type VARCHAR, length 50

on my php page, I have this code:

      $conn = mysql_connect('SERVER_NAME','USERNAME','PASSWORD');
      $sql = "INSERT INTO MailingList (Address,Name) VALUES ('$EmailAddress', '$Name')";

so the page has to be sent in this format:

Now that that part's set up, we just have to have flash interact with it.

First, you need to create 2 text fields and make them input text fields in the properties inspector. You'll have the option for static text, dynamic text or input text...choose input for both.

I named the first one txtEmailAddress and the second one txtName, for consistency with the variables we'll send. Select the text field, and you can name it in the properties inspector, right under where you made them input text fields. Also, make sure you display their outlines. You'll press a button that's in a set of 3 buttons in the middle of the properties inspector. It'd also be a good idea to put text fields next to them to say what they are. i.e., put a text field with the text "email address" next to the txtEmailAddress field, so people can tell what they're putting into the field.

We also need a button. I made a movie clip named mcSubmit and put a rectangle with some text in it. It doesn't matter what you name it when you create it, but it needs to be named (in the same way as you name text fields) mcSubmit for the code I'm going to create. If you change mcSubmit to something else, you need to change the button/movie clip's name on the stage as well as in the code.

The basic idea is to use the built in LoadVars function, which works pretty well, once you get the hang of it. Essentially, it sends out variables to a page and gets any variables on the page and loads them back in. You can choose to only send variables, or to only load variables, but we're going to do both, so that we don't have to open a new window.

First, create a new layer and call it actions. Click on its first frame and hit F9 to bring up the actions panel.

Paste the following code in:

mcSubmit.onRelease = function() {
      var lvMailingList:LoadVars = new LoadVars();
      lvMailingList.onLoad = function(success:Boolean) {
            if (success) {
                  //anything to do after it's been entered into the database
      lvMailingList.EmailAddress = txtEmailAddress.text;
      lvMailingList.Name = txtName.text;
      lvMailingList.sendAndLoad("", lvMailingList, "POST");

I'm assuming you have MX 2004. If so, this code should work.

You can use my examples if you want.

Have fun!

Author Comment

ID: 12052706

Thanks so much for the help. I'm working on it. I just have MX but I don't suppose that that really matters? I'll let you know how it goes.


Expert Comment

ID: 12054303
i don't think mx will let you do strict data typing, so change this line
 var lvMailingList:LoadVars = new LoadVars();
 var lvMailingList = new LoadVars();

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Software Restriction Policy 8 856
How to emebed .XML into  flash to make a self contained .SWF 1 175
free photo watermark software 5 77
Adobe Indesign CS6 4 99
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now