Solved

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

Posted on 2004-09-10
4
178 Views
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:
http://maroon5.com/main_site/main.html 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.
0
Comment
Question by:imawake
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:imawake
ID: 12034916
Anyone?
0
 
LVL 4

Accepted Solution

by:
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');
      mysql_select_db("DATABASE");
      $sql = "INSERT INTO MailingList (Address,Name) VALUES ('$EmailAddress', '$Name')";
      mysql_query($sql);
      mysql_close($conn);
?>

so the page has to be sent in this format:
http://www.yoursite.com/mailing_list.php?EmailAddress=someone@blah.com&Name=someone

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("http://www.yoursite.com/mailing_list.php", lvMailingList, "POST");
};

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

You can use my examples if you want.

http://www.squirreltweezers.com/development/mailing_list.swf
http://www.squirreltweezers.com/development/mailing_list.fla

Have fun!
0
 

Author Comment

by:imawake
ID: 12052706
Hi,

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.

 
0
 
LVL 4

Expert Comment

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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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.

707 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