Roc
01-03-2008, 02:57 PM
I was following the tutorial here for making a form in flash and then sending the collected data to a mail address using PHP.
The setup doesnt seem to work as I did not get any email. Can anyone help me find a solution to this or let me know how to troubleshoot it?
Here is the actionscript
stop();
// Making the default setting for below mentioned textfields
fname = "";
lname = "";
email = "";
phone = "";
college = "";
events = "";
// Making '*' Marks Invisible
fnamemark._visible = false;
lnamemark._visible = false;
emailmark._visible = false;
phonemark._visible = false;
collegemark._visible = false;
eventsmark._visible = false;
//
//-------------------------------------------------------
// Submit Button action
btnSubmit.onRelease = function() {
//Add Path of the php file
feedbackpath = "mailto.php";
//
str1 = email.indexOf("@");
str2 = email.indexOf("@")+1;
str3 = email.charAt(str1+1);
str4 = email.lastIndexOf(".");
str5 = email.charAt(str4+1);
len = length(email);
counter = 1;
flag = 0;
while (Number(counter)<=Number(len)) {
Char = substring(email, counter, 1);
if (Char ne "@") {
flag = Number(flag)+1;
}
counter = Number(counter)+1;
}
//
//First Name field validation
if (fname == "") {
condition1 = "";
fnamemark._visible = true;
} else {
condition1 = "ok";
fnamemark._visible = false;
}
//Last Name field validation
if (lname == "") {
condition2 = "";
lnamemark._visible = true;
} else {
condition2 = "ok";
lnamemark._visible = false;
}
//E-Mail Address validation
if (str4<=str2 || str3 == "." || str5 == "" || Number(flag) != Number(len-1)) {
condition3 = "";
emailmark._visible = true;
} else {
condition3 = "ok";
emailmark._visible = false;
}
//Phone field validation
if (phone == "") {
condition4 = "";
phonemark._visible = true;
} else {
condition4 = "ok";
phonemark._visible = false;
}
//College field validation
if (college == "") {
condition5 = "";
collegemark._visible = true;
} else {
condition5 = "ok";
collegemark._visible = false;
}
//Events field validation
if (events == "") {
condition6 = "";
eventsmark._visible = true;
} else {
condition6 = "ok";
eventsmark._visible = false;
}
//Sending data to php file only if all the above validations are fulfilled
if (condition1 == "ok" && condition2 == "ok" && condition3 == "ok" && condition4 == "ok" && condition5 == "ok" && condition6 == "ok") {
loadVariablesNum(feedbackpath+"&fname="+fname+"&lname="+lname+"&email="+email+"&phone="+phone+"&college="+college+"&events="+events, 0);
gotoAndStop(2);
}
};
//
//-------------------------------------------------------
// Reset Button action
btnReset.onRelease = function() {
// Making the default setting for below mentioned textfields
fname = "";
lname = "";
email = "";
phone = "";
college = "";
events = "";
// Making '*' Marks Invisible
fnamemark._visible = false;
lnamemark._visible = false;
emailmark._visible = false;
phonemark._visible = false;
collegemark._visible = false;
eventsmark._visible = false;
};
And the PHP code
<?
//Destination Email ID
$to = "xxx@gmail.com";
//First Name of the Person
$fnamenew = $_GET['fname'];
//Last Name of the Person
$lnamenew = $_GET['lname'];
//Email Id of the person
$emailnew = $_GET['email'];
//Phone of the person
$phonenew = $_GET['phone'];
//College of the person
$collegenew = $_GET['college'];
//Event Names
$eventsnew = $_GET['events'];
//Subject line of the email
$subject = "Registration:"." "."$collegenew"." "."$fnamenew"." "."$lnamenew";
/*********** Email body *******************/
$matter = "Below are the registration details\n\n".
"First Name:"." "."$fnamenew"."\n\n".
"Last Name:"." "."$lnamenew"."\n\n".
"Email:"." "."$emailnew"."\n\n".
"Phone:"." "."$phonenew"."\n\n".
"College:"." "."$collegenew"."\n\n".
"Events:"." "."$eventsnew"."\n\n";
/**********************************************/
mail("$to", "$subject","$matter","From: $emailnew");
?>
The setup doesnt seem to work as I did not get any email. Can anyone help me find a solution to this or let me know how to troubleshoot it?
Here is the actionscript
stop();
// Making the default setting for below mentioned textfields
fname = "";
lname = "";
email = "";
phone = "";
college = "";
events = "";
// Making '*' Marks Invisible
fnamemark._visible = false;
lnamemark._visible = false;
emailmark._visible = false;
phonemark._visible = false;
collegemark._visible = false;
eventsmark._visible = false;
//
//-------------------------------------------------------
// Submit Button action
btnSubmit.onRelease = function() {
//Add Path of the php file
feedbackpath = "mailto.php";
//
str1 = email.indexOf("@");
str2 = email.indexOf("@")+1;
str3 = email.charAt(str1+1);
str4 = email.lastIndexOf(".");
str5 = email.charAt(str4+1);
len = length(email);
counter = 1;
flag = 0;
while (Number(counter)<=Number(len)) {
Char = substring(email, counter, 1);
if (Char ne "@") {
flag = Number(flag)+1;
}
counter = Number(counter)+1;
}
//
//First Name field validation
if (fname == "") {
condition1 = "";
fnamemark._visible = true;
} else {
condition1 = "ok";
fnamemark._visible = false;
}
//Last Name field validation
if (lname == "") {
condition2 = "";
lnamemark._visible = true;
} else {
condition2 = "ok";
lnamemark._visible = false;
}
//E-Mail Address validation
if (str4<=str2 || str3 == "." || str5 == "" || Number(flag) != Number(len-1)) {
condition3 = "";
emailmark._visible = true;
} else {
condition3 = "ok";
emailmark._visible = false;
}
//Phone field validation
if (phone == "") {
condition4 = "";
phonemark._visible = true;
} else {
condition4 = "ok";
phonemark._visible = false;
}
//College field validation
if (college == "") {
condition5 = "";
collegemark._visible = true;
} else {
condition5 = "ok";
collegemark._visible = false;
}
//Events field validation
if (events == "") {
condition6 = "";
eventsmark._visible = true;
} else {
condition6 = "ok";
eventsmark._visible = false;
}
//Sending data to php file only if all the above validations are fulfilled
if (condition1 == "ok" && condition2 == "ok" && condition3 == "ok" && condition4 == "ok" && condition5 == "ok" && condition6 == "ok") {
loadVariablesNum(feedbackpath+"&fname="+fname+"&lname="+lname+"&email="+email+"&phone="+phone+"&college="+college+"&events="+events, 0);
gotoAndStop(2);
}
};
//
//-------------------------------------------------------
// Reset Button action
btnReset.onRelease = function() {
// Making the default setting for below mentioned textfields
fname = "";
lname = "";
email = "";
phone = "";
college = "";
events = "";
// Making '*' Marks Invisible
fnamemark._visible = false;
lnamemark._visible = false;
emailmark._visible = false;
phonemark._visible = false;
collegemark._visible = false;
eventsmark._visible = false;
};
And the PHP code
<?
//Destination Email ID
$to = "xxx@gmail.com";
//First Name of the Person
$fnamenew = $_GET['fname'];
//Last Name of the Person
$lnamenew = $_GET['lname'];
//Email Id of the person
$emailnew = $_GET['email'];
//Phone of the person
$phonenew = $_GET['phone'];
//College of the person
$collegenew = $_GET['college'];
//Event Names
$eventsnew = $_GET['events'];
//Subject line of the email
$subject = "Registration:"." "."$collegenew"." "."$fnamenew"." "."$lnamenew";
/*********** Email body *******************/
$matter = "Below are the registration details\n\n".
"First Name:"." "."$fnamenew"."\n\n".
"Last Name:"." "."$lnamenew"."\n\n".
"Email:"." "."$emailnew"."\n\n".
"Phone:"." "."$phonenew"."\n\n".
"College:"." "."$collegenew"."\n\n".
"Events:"." "."$eventsnew"."\n\n";
/**********************************************/
mail("$to", "$subject","$matter","From: $emailnew");
?>