Solved

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

Posted on 2004-09-10
4
169 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
  • 2
  • 2
4 Comments
 

Author Comment

by:imawake
Comment Utility
Anyone?
0
 
LVL 4

Accepted Solution

by:
mrdilliard earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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 what frame rate is, how to control it and what effect it has on the video.

771 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

11 Experts available now in Live!

Get 1:1 Help Now