PDA

View Full Version : mailing list subscription


flashnewb3
10-13-2006, 02:10 PM
I'm sorry to bug you guys for such an easy thing. I've been looking all over these forums, seen probably close to 30 different examples of simple mailers or mailing list subscribers, I've been through the tutorial here as well as a couple of others and still can't manage to even send out an email (I'm pretty weak at actionscript and programming in general, I hope to take some classes after I graduate to better understand flash and web design). Basically, I just want something where the user puts in their email and clicks submit. Then an email goes to our band's email and says that this email address wants to be put on the mailing list. That's all I need it to do. I know I have php enabled on my web server, so I don't think it's a server side issue. I'm pretty sure it's in the actionscript or php script that I'm running (it's the same one as the tutorial here on actionscript.com). If anyone can help me it would be greatly appreciated.

PHP script
<?php
mail("rememberingcrimson@gmail.com",$_GET["Fan to be added to the mailing list"],$_GET["Mail list contact, get on it Marty!"], "From: PHPMailer\nReply-To: $_GET["from"]\nX-Mailer: PHP/" . phpversion());
?>

Actionscript
on (release) {
if (from eq "") {
stop();
} else {
var my_lv:LoadVars = new LoadVars();
my_lv.sendAndLoad("http://www.rememberingcrimson.com/tempbs/mail.php4", my_lv, "POST");
getURL("javascript:openNewWindow('mailinglist.html', 'thewin', 'width = 250, height=200, toolbar=no, scrollbar=no');");
gotoAndPlay(182);
}
}

That is the actionscript on my button, do I need something for my text field that takes the email address?
Thanks in advance for the help.

Morg
10-13-2006, 03:25 PM
Welcome to the forums.

This has been covered at length in other posts... Please search before you post.

Theres also a tutorial/sample file... http://actionscript.org/forums/showpost.php3?p=421960&postcount=70

On first glance, your $_GET should be $_POST... but look at those tutorials. They should help you. And don't forget to search before psting. :D

flashnewb3
10-13-2006, 05:27 PM
I have searched the forums high and low, found tons of articles on it and still have not managed to get it to work with everything I've tried. I always search a forum before posting ;) but I have tried a ton of stuff from these forums, the tutorials here and the forums and tutorials from other places without any luck. I'm sorry for being such a pain, but I was hoping someone could walk me through the steps of just setting up the mailer, cuz no matter how much I read and try I can't seem to get it to work. I also have checked out that tutorial already ;) Here is my updated code:

Actionscript:

on (release) {
var my_lv:LoadVars = new LoadVars();\
if (my_lv.email_txt eq "") {
stop();
} else {
my_lv.subject_txt.text = "A fan wants to be on our mailing list!";
my_lv.message_txt.text = "Mail list contact, get on it Marty!";
my_lv.email_txt = email_txt.text;
my_lv.sendAndLoad("http://www.rememberingcrimson.com/tempbs/SendMail.php", my_lv, "POST");
getURL("javascript:openNewWindow('mailinglist.html', 'thewin', 'width = 250, height=200, toolbar=no, scrollbar=no');");
gotoAndPlay(182);
}
}

and the php file

<?php //tells the server this is php

//-------------------------------------
// the below code set the headers. There can be a bit difficult to understand fully.
// Information about them and all the commands below can be found at the PHP manual
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Remembering Crimson <' . $_POST['email_txt'] . '>' . "\r\n"; //you can put your websites name in here or anything else you like
//$headers .= 'Bcc: another@email.com' . "\r\n"; //this is optional.
//------------------------------

// gets variables from flash
$to = "rememberingcrimson@gmail.com"; //inset the email address it goes to here
$subject = $_POST['subject_txt'];
$message = $_POST['message_txt'];

if ($_POST['message_txt'] != "") { //this checks to make sure someone didn't visit the page manually by making sure message_txt is not empty
$ok = mail($to, $subject, $message, $headers); //this line sends the mail and returns true or false
if($ok) {
echo "&server_mes=ok&"; //if mail was send print to the screen "&server_mes=ok"
} else {
echo "&server_mes=fail&"; // if mail was NOT sent, print to the screen "&server_mes=fail"
}
}

// closes the php session
?>

If you can look through it that would be great, it's straight out of the link you posted above. Also, I'm using Flash 8, not MX 2004, does that make a difference? Dreamweaver is being used for the PHP code as well. Thanks again.

flashnewb3
10-16-2006, 05:31 PM
Welcome to the forums.

This has been covered at length in other posts... Please search before you post.

Theres also a tutorial/sample file... http://actionscript.org/forums/showpost.php3?p=421960&postcount=70

On first glance, your $_GET should be $_POST... but look at those tutorials. They should help you. And don't forget to search before psting. :D


That tutorial also doesn't work, because I tried it on my site and nothing got sent to the email. The only thing I changed was the email it was sent to on line 13 of the php script. Nothing happened.

flashnewb3
11-02-2006, 04:26 PM
Does anyone know if Flash 8 and the Flash MX2004 tutorial for the javascript mailer is compatible? I can't get my javascript working for a simple mailer where the user types in there email to a field and it sends an automated email to our email addrees. Plz help!! Thanks in advance.

Morg
11-03-2006, 07:30 AM
hmmm, I didnt actually work through the tutorial - just assumed it would work.
What I do is use a PHP page that sends a mail. It is available on the forums here. Search in the backend/server side threads.

Lemme know when you find it.

Cota
11-03-2006, 07:36 AM
The tutorial does work. Few things, never declare a loadvars object in the onRelease handler, and avoid using "eq" (I dont know why, thats just the way I learned)...and yes, "GET" should be "POST"

Morg
11-03-2006, 07:48 AM
haha! Assume makes an ASS out of U and ME.. hehe :D Apologies Cota.

I know theres one on here somewhere that works. I used it and use it often... :(

Cota
11-03-2006, 07:51 AM
Flash Gordon and I tested it before we posted..its been through 2 revisions as well...no apologies needed you assumed correctly.

flashnewb3
11-03-2006, 02:45 PM
Let me show you the updated script.

PHP script:

<?php //tells the server this is php

//-------------------------------------
// the below code set the headers. There can be a bit difficult to understand fully.
// Information about them and all the commands below can be found at the PHP manual
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Remembering Crimson <' . $_POST['email_txt'] . '>' . "\r\n"; //you can put your websites name in here or anything else you like
//$headers .= 'Bcc: another@email.com' . "\r\n"; //this is optional.
//------------------------------

// gets variables from flash
$to = "rc@rememberingcrimson.com"; //inset the email address it goes to here
$subject = $_POST['subject_txt'];
$message = $_POST['message_txt'];

//if ($_POST['message_txt'] != "") { //this checks to make sure someone didn't visit the page manually by making sure message_txt is not empty
$ok = mail($to, $subject, $message, $headers); //this line sends the mail and returns true or false
if($ok) {
echo "&server_mes=ok&"; //if mail was send print to the screen "&server_mes=ok"
} else {
echo "&server_mes=fail&"; // if mail was NOT sent, print to the screen "&server_mes=fail"
}
}

// closes the php session
?>


on (release) {
var my_lv:LoadVars = new LoadVars();
if(email_txt == ""){
stop();
}
else{
my_lv.subject_txt.text = "One of our adoring fans wants to be on our mailing list!";
my_lv.message_txt.text = "Mail list contact, get on it Marty!";
my_lv.email_txt = email_txt.text;
my_lv.sendAndLoad("SendMail.php4", my_lv, "POST");
getURL("javascript:openNewWindow('mailinglist.html', 'thewin', 'width = 350, height=300, toolbar=no, scrollbar=no');");
gotoAndPlay(182);
}
}

I tried declaring the loadVars outside of the on handler and it gave me an error. For some reason I get through the code, because I get a pop-up window which indicates it hits the getURL line. So I'm not sure where I'm going wrong, whether it be in the code or on the hosts side (I have php enabled, and all the php extensions are usable: php, php3, php4). Thanks for the help, I didn't mean to say the tutorial didn't work, I meant to say it didn't work for me. Thanks again.

Cota
11-03-2006, 07:00 PM
What error did it give and where's the onLoad handler for the loadvars()?