However, I had to change it so that the comments box had a scroll bar. To do this, I had to put the comments input text box, which is labeled Var:comments into a separate movie clip. Now it scrolls and my email sends, but it doesn't send anything you type in the comments box. I think there is a problem with my routing...somehow I need to tell the mailer to look within the movie clip (instance name: myInput) for the Var:comments.
Here is the code in the actions layer on the root timeline:
stop();
// this variable will decide if the email address is in the correct format
a =0;
// validates the email field for @ symbol and a . at the end
function validate () {
if (from.length>=7) {
if (from.indexOf("@")>0) {
if ((from.indexOf("@")+2)<from.lastIndexOf(".")) {
if (from.lastIndexOf(".")<(from.length-2)) {
a = 1;
// email is fine
}
}
}
}
}
// checks for empty fields then calls email check function
function formcheck () {
validate ();
trace(a);
if (fname = "" or telno eq "" or comments eq "" or from eq "") {
stop();
error = "You have left blank fields, please fill in all fields, thank you";
} else {
emailcheck ();
}
}
// email check function calls the fucntion at the top, if its satisfied it loads the php script and sends you to frame 2
function emailcheck (){
if (a != 1){
stop();
error = "Email address not valid";
} else {
loadVariablesNum("mail.php3", 0, "POST");
gotoAndStop(2);
}
}
That tutorial is very old (Flash 5). I would not use it in the present form. loadVariablesNum has several problems and one of them is dealing with levels. I changed the fla including LoadVars and including your new movieclip.
- The right of the People to create Flash movies shall not be infringed. -
Awesome! Thanks! It works...with one little glich. When you click Send it now launches mail.php3 in a new blank window. How can I make this not happen?
Ok, that fixed that problem, and I double checked the variable names, but we have made a new problem. Now when I click send, the Name entry field momentarily reads "false" before before going to the thanks for sending message on frame 2 of the main timeline.
Thanks again for all of your help. It is greatly appreciated!!
I updated the original file with the correct code and am attaching here for future users. You will have to add your own scroller since I bought mine and as such, cannot distribute.
I'm also trying to get this mailer to work and after rereading all of the posts I noticed that loadvars() was stated to have issues with levels. My contact appears on level four of my flash movie. How should I modify Cancerinform's code to get that to work?
Well I fixed the files as needed, so that the variables would be picked up from my movie:
PHP Code:
var a =0;
function validate (){
if (it_email.text.length >= 7){
if (it_email.text.indexOf ("@") > 0){
if ((it_email.text.indexOf ("@") + 2) < it_email.text.lastIndexOf (".")){
if (it_email.text.lastIndexOf (".") < (it_email.text.length - 2)){
a = 1;
// email is fine
}
}
}
}
}
// checks for empty fields then calls email check function
function formcheck () {
validate ();
trace(a);
if (it_name.text == "" || it_email.text == "" || it_zip.text == "" || it_comment.text == "") {
stop();
error = "You have left blank fields, please fill in all fields. Thank you!";
} else {
emailcheck ();
}
}
// email check function calls the fucntion at the top, if its satisfied it loads the php script and sends you to frame 2
function emailcheck (){
var lv:LoadVars = new LoadVars();
var lvAnswer:LoadVars = new LoadVars ();
if (a != 1){
stop ();
error = "Email address not valid.";
} else {
lv.name = it_name.text;
lv.email = it_email.text;
lv.zip = it_zip.text;
lv.comment = it_comment.text;
trace (lv.name);
trace (lv.email);
trace (lv.zip);
trace (lv.comment);
lv.sendAndLoad ("mail.php3", lvAnswer, "POST");
lvAnswer.onLoad = function () {
gotoAndStop ("Sent");
};
}
}
mail("$adminaddress","Contact Page",
"A customer at $sitename has commented\n
Name: $name Email: $email\n
Zip: $zip The visitor commented:
-----------------------------------------------------------------------------------------
$comment
Logged Info :
-----------------------------------------------------------------------------------------
Using: $HTTP_USER_AGENT Hostname: $ip IP address: $REMOTE_ADDR Date/Time: $date","FROM:$adminaddress");
?>
Nothing happens after this point...however this script is in a .swf that is called to level 4, would that be an issue?
I have never sent from a different level but try a number traces. If you cannot do traces because of a test on the server add a textfield and test if you get a response within the onLoad function.
Another possibility is to add "this" to all variables and for lv
var lv:LoadVars = new LoadVars();
var lvAnswer:LoadVars = new LoadVars ();
lv = this.lv;
lvAnswer = this.lvAnswer;
- The right of the People to create Flash movies shall not be infringed. -
Another possibility is to add "this" to all variables and for lv
var lv:LoadVars = new LoadVars();
var lvAnswer:LoadVars = new LoadVars ();
lv = this.lv;
lvAnswer = this.lvAnswer;
Fixed the problem! It was so much easier than I thought....but it turns out that the server I was using would not allow PHP3.....so I redid it in .ASP.