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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pushing Adobe Flash Player Fails with Error %%2 1 481
Some Flash in IE doesn't display properly, but does in Chrome 4 626
FLV versus SWF 11 277
Removing Flash from Website 6 65
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
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.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

773 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