PDA

View Full Version : Help me to get my Mailing List to work.


Asparagus
08-18-2004, 12:51 AM
As quickly and simply as I can, I'll explain...

WHAT IS IT: A mailing list, where the user enters NAME & EMAIL and, with the use of radio-type buttons, they can chose the format of the newsletter (PLAIN TEXT or RICH TEXT) and also the language (ENGLISH or DANISH).

WHAT IS WRONG: Doesn't forward the info to the owner, but does send a confirmation email to the user (but not all users??).

WHY: I don't know, that's why I'm here. Please help!

WHO: You! Any help wil be greeeeeeeeeaaaaaaaaatly appreciated

CODES WITHIN THE .FLA:

Frame1:fscommand ("allowscale", "false");
//
// set some variables
//
mailform = "mailinglist.php";
confirm = "please wait for confirmation ...";
action = "send";
//
// and focus on variable fname
//
Selection.setFocus("fname");
//
// validate email function
//
function validate (address) {
if (address.length>=7) {
if (address.indexOf("@")>0) {
if ((address.indexOf("@")+2)<address.lastIndexOf(".")) {
if (address.lastIndexOf(".")<(address.length-2)) {
return (true);
}
}
}
}
return (false);
}
//
// form check
//
function formcheck () {
if ((((email == null)) || (email.length<1)) || (email == "Address not valid...")) {
email = "Address not valid...";
action = "";
}
if (!validate(email)) {
email = "Address not valid...";
action = "";
}
if (fname == null) {
fname = "Name required...";
action = "";
}
if ((validate(email)) && (email != "ERROR!") && (fname != "") && (lname != "")) {
action = "send";
loadVariablesNum (mailform, 0, "POST");
gotoAndPlay ("wait");
}
}
stop ();Frame5:loadVariablesNum(mailform, 2);
answer = confirm;
On the 'Subcribe' button:on (release) {
formcheck();
trace('language '+lang+'\nformat '+format+'\nemail '+email);
}And here's the .PHP script:<?

// Enter your contact email address here
$adminaddress = "XXXXX@XXXXX.com";

// Enter the address of your website here include http://www.
$siteaddress ="http://www.XXXXX.com";

// Enter your company name or site name here
$sitename = "XXXXX";

/************************************************** *****

No need to change anything below unless you want to add or subtract functions or change the wording of things sent back to the flash file ...

************************************************** *****/

// Gets the date and time from your server
$date = date("m/d/Y H:i:s");

// Gets the IP Address
if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);

//Process the form data!
// and send the information collected in the Flash form to Your nominated email address
if ($action != ""):
mail("$adminaddress","New Subscription",
"A visitor at $sitename subscribed to your mailing list.\n
Name: $name
Email: $email
Language: $lang
Format: $format

Logged Info :
------------------------------
Using: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Time: $date","FROM:$adminaddress");

//This sends a confirmation to your visitor
mail("$email","XXXXX",
"Hej $name,\n
Du er nu med på mailinglisten tilhørende XXXXX.
Tak,
$sitename
$siteaddress
----------------------
Hi $name,\n
You have now joined the mailinglist belonging to XXXXX.
Thank you,
$sitename
$siteaddress","FROM:$adminaddress");

//Confirmation is sent back to the Flash form that the process is complete
$sendresult = "Thanks for joining XXXX
mailing list. You will receive a
confirmation email shortly.";
$send_answer = "answer=";
$send_answer .= rawurlencode($sendresult);
echo "$send_answer";

endif;

?>

nathanleyton
08-27-2004, 04:59 PM
forget loadVariablesNum and think about loadVars

so here we go.
instead of.
loadVariablesNum (mailform, 0, "POST");
use

sendMail = new LoadVars();
sendMail.email = email;
sendMail.fname = fname;
sendMail.onLoad = function(success) {
if (success) {
//load successfull you can put code here.
}
}
sendMail.sendAndLoad(mailform, sendMail, "POST");

then php you need

$email = $_REQUEST['email'];
$fname= $_REQUEST['fname'];


allt his stufff you can erad about on the forum and on php.net

i have probably put typos in this but i sure you can work through it.

Nathan