How do all,
Ive got a bit of a problem…Ive done a Flash form with a movieclip that wants to sends variables to an ASP script which works fine except my host doesnt support ASP do the ASP code needs to be converted to PHP…only trouble is I know little about PHP at the mo and my deadlines are pretty tight.
This is my Flash form code:
stop();
submitbutton.onRelease = function() {
onSubmit();
};
resetbutton.onRelease = function() {
onReset();
};
// Array of the instance names of the checkboxes
myCheck = [newlicense_cb, renewal_cb, general_cb];
// Function
function checkDisplay(component) {
var j, s;
for (j in myCheck) {
if (myCheck[j].getValue()) {
s += myCheck[j].getLabel()+"
";
}
}
checke = "Requires more information about :
"+((s.length) ? s : "None at present");
}
// As usual...
for (i=0; i<myCheck.length; i++) {
myCheck*.setChangeHandler("checkDisplay");
}
function onReset() {
firstname = "";
surname = "";
address = "";
telephone = "";
fax = "";
email = "";
comments = "";
newlicense_cb.setValue(false);
renewal_cb.setValue(false);
general_cb.setValue(false);
}
function onSubmit() {
if (!email.length || email.indexOf("@") == -1 || email.indexOf(".") == -1) {
message_txt.text = "Please enter a valid email address";
} else if (!firstname.length) {
message_txt.text = "Please enter your name";
} else if (!surname.length) {
message_txt.text = "Please enter your surname";
} else {
formData = new LoadVars();
formData.firstname = firstname;
formData.surname = surname;
formData.address = address;
formData.telephone = telephone;
formData.fax = fax;
formData.email = email;
formData.comments = comments;
formData.info = checke;
// Get radio button selection:
replyData = new LoadVars();
// And define a callback handler for that instance:
replyData.onLoad = handleReply;
// Initialize replyData variables:
replyData.reply_firstname = "";
replyData.reply_info = "";
formData.sendAndLoad("mail.asp", replyData);
message_txt.text = "Submitting request, please wait...";
}
}
function handleReply(success) {
if (success == true) {
_root.contentsmc.thanks_mc.gotoAndPlay(2);
message_txt.text = "Thank you "+replyData.reply_firstname+" ,we will contact you soon";
onReset();
submitbutton.enabled = false;
resetbutton.enabled = false;
} else {
message_txt.text += "Error, please try again";
onReset();
}
}
And this is the ASP code I used (by the way…an exworkmate coded this):
<%
Dim reply_firstname, returnToFlash
reply_firstname = Request.Form("firstname")
returnToFlash = "reply_firstname=" & Server.URLEncode(reply_firstname)
Response.Write returnToFlash
Dim MyBody
Dim MyCDONTSMail
Set MyCDONTSMail = CreateObject("CDONTS.NewMail")
MyCDONTSMail.From= Trim( Request.Form("email") )
MyCDONTSMail.To= "andy@mindofdesign.com"
MyCDONTSMail.CC= "andy@mindofdesign.com"
MyCDONTSMail.Subject= "Enquiry from website"
MyBody = MyBody & "" & vbCrLf
MyBody = MyBody & Trim( Request.Form("firstname") ) & vbCrLf
MyBody = MyBody & Trim( Request.Form("surname") ) & vbCrLf
MyBody = MyBody & "" & vbCrLf
MyBody = MyBody & Trim( Request.Form("address") ) & vbCrLf
MyBody = MyBody & "" & vbCrLf
MyBody = MyBody & Trim( Request.Form("telephone") ) & vbCrLf
MyBody = MyBody & "" & vbCrLf
MyBody = MyBody & Trim( Request.Form("email") ) & vbCrLf
MyBody = MyBody & "" & vbCrLf
MyBody = MyBody & "Advice Required is: " & vbCrLf
MyBody = MyBody & Trim( Request.Form("room") ) & vbCrLf
MyBody = MyBody & "" & vbCrLf
MyBody = MyBody & Trim( Request.Form("info") ) & vbCrLf
MyBody = MyBody & "" & vbCrLf
MyBody = MyBody & "Message: " & vbCrLf
MyBody = MyBody & Trim( Request.Form("comments") ) & vbCrLf
MyCDONTSMail.Body= MyBody
MyCDONTSMail.Send
set MyCDONTSMail=nothing
%>
Now Ive had a go at the PHP but Im not convinced it’s right:
<?php
$to = 'andy@mindofdesign.com';
$subject = 'Enquiry from website';
$address = $_POST["address"];
$telephone = $_POST["telephone"];
$email = $_POST["email"];
$info = $_POST["info"];
$comments = $_POST["comments"];
mail($to, $subject, $address, $telephone, $email, $info, $comments);
?>
I think the Actionscript needs tweeking aswell because the code is within a movieclip called ‘contentmc’…the line wants to read:
this.formData.sendAndLoad("mail.asp", replyData);
I think?
Be grateful for some help!
Thanks!
Andy