l = new LoadVars();
r = new Array("address:", "subject:", "message:");
for (var i = 0; i<r.length; i++) {
l.a[i] = "";
this.createTextField("tf"+i, i, 0, 40*i, 400, 22);
this["tf"+i].text = r[i];
this["tf"+i].border = true;
this["tf"+i].type = "input";
this["tf"+i].q = i;
this["tf"+i].onChanged = function() {
l["a"+this.q] = this.text;
};
}
k = new Object();
Key.addListener(k);
k.onKeyDown = function() {
if (Key.isDown(Key.ENTER)) {
l.sendAndLoad("mail.php", l, "POST");
}
};
(untested)
4. save and publish.
5. copy both the swf and the mail.php and copy them to your server. both files need to be in the same directory.
6. you have to chmod the mail.php form to all executable. if you're using IE's ftp, just right-click it and check all the boxes on the far right (there are 3 rows of 3 boxes each).
that's pretty much it, but php requires a program to work. chances are you don't have this programming running, although i could be wrong. that means if you test this on your local machine, it wont send a mail, but should be fine when hosted on your server.
never let the flash form specify the destination address unless you really need (and then take some precautions against abuse)
You have just created a means for some idiot to send a few thousand "cheap viagra" mails with your server as sender
maybe some dialogue between the movie and the server, to ensure that the request indeed comes from a flash form, rather than a submission script.
I could also imagine that using flash remoting instead of loadvars would help a bit - spammers likely would go and look for an easier target
i cant disagree that security is always a good idea, but with an average spammail weighing in at somewhere around 3-4kb, and bandwidth going for a gig a penny, i'd have to say it's not something i'd consider worth the worry
a) you probably do not want certain types of spam sent with YOUR domain as the sender
b) sending spam is likely to cause mail blocking - if you are on a shared server together with some 20 other domains, a notable part of the internet might refuse to accept mails from these 20 domains as well (or even from all domains hosted by the same hosting company)
You are likely to get some nasty letters from affected people
Just as an example, I get internet access and email from a big provider. It occasionally happens that one of their clients gets infected with some mail-sender pests. As a consequence another big provider (rr.com - which incidentally is known throughout the world as a source of spam) decided to block all mails from that network.
Staying in touch with people was an unpleasant and time-comsuming experience - and I really would not want to resort to international phone calls
but how do i create the content in the flash to support the php
i don't know how to code the little dynamic text boxes.
like for the first box i just want name
user to put in name
second will be the comments section.
so basically creating the dynamic text boxes...allowing the user to put in the info...to be sent via email to me on submission.
( so basically how do i script the dynamic text boxes in flash to work with the php)
-------------------------------------------------------------------
1. open notepad. paste this
code:<?php$a= $_POST['a0'];$s = $_POST['a1'];$m = $_POST['a2'];mail($a,$s,$m);?>
2. save it as mail.php.
3. open a new fla. paste this
ActionScript:{l = new LoadVars();
r = new Array("address:", "subject:", "message:");
for (var i = 0; i<r.length; i++) {
l.a[i] = "";
this.createTextField("tf"+i, i, 0, 40*i, 400, 22);
this["tf"+i].text = r[i];
this["tf"+i].border = true;
this["tf"+i].type = "input";
this["tf"+i].q = i;
this["tf"+i].onChanged = function() {
l["a"+this.q] = this.text;
};
}
k = new Object();
Key.addListener(k);
k.onKeyDown = function() {
if (Key.isDown(Key.ENTER)) {
l.sendAndLoad("mail.php", l, "POST");
}
};
(untested)
4. save and publish.
5. copy both the swf and the mail.php and copy them to your server. both files need to be in the same directory.
6. you have to chmod the mail.php form to all executable. if you're using IE's ftp, just right-click it and check all the boxes on the far right (there are 3 rows of 3 boxes each).
that's pretty much it, but php requires a program to work. chances are you don't have this programming running, although i could be wrong. that means if you test this on your local machine, it wont send a mail, but should be fine when hosted on your server.
***** and isn't there a piece of info missing about a button ????? Aren't i supposed to attach some actionscript to a button and make one ?
k.onKeyDown = function() {
if (Key.isDown(Key.ENTER)) {
l.sendAndLoad("mail.php", l, "POST");
}
};
//IS ENTER A INSTANCE NAME OF THE BUTTON ???// OR THE ENTER KEY ON THE KEYBOARD ?
IVE HEARD ALL OF YOU GUYS COMMENTS GOOD AND BAD., HOW IS THE BEST WAY TO DO THIS ??
on (release) {
mylv = new LoadVars();
mylv.name = name.text;
mylv.email = email.text;
mylv.message = message.text;
myreply = new LoadVars();
mylv.sendAndLoad('mail.php', myreply, 'POST');
}
You may want to add later
- check that fields are not empty
- check that email looks like email (has @ in the middle and at least one period to the right)
- display a message that mail was sent or could not be sent