Here's what I've been testing, using the code you posted earlier in the thread. I've deleted your opening comments and commented out the serverLang:String:
var email_lv:LoadVars = new LoadVars();
//this function is called when email_lv loads the server-side script.
email_lv.onLoad = function(success) {
//If the script was successfully loaded, this condition is run
if (success) {
/* Though the server-side script was loaded, it does not mean it was
executed successfully. This condition gets a response from the
server-side script and determines if it was truly successful. */
if (email_lv.server_mes == "ok") {
status_txt.text = "Email Sent";
/* You can add additional code here. This is only run
if everything went as planned. */
}
} else {
//email failed to send, but script did load. Likely a server issue.
status_txt.text = "Email Failed";
}
};
/*This is the onRelease function for "submit_btn" button. This is only run
if the button was pressed. */
submit_btn.onRelease = function() {
/* Here we are validating the data. This insures the email address contains
both the "@" and ".", If not, it stops the script and alerts the user. */
if (!email_txt.length || email_txt.indexOf("@") == -1 || email_txt.indexOf(".") == -1) {
status_txt.text = "Invalid Email.";
//This validates the subject line contains text
} else if (!subject_txt.length) {
status_txt.text = "Missing Subject";
//This validates the message body contains text
} else if (!message_txt.length) {
status_txt.text = "Missing Message";
//If everything is filled out correctly, this is run.
} else {
//Collects the data from the text boxes and gives it to email_lv
email_lv.email_txt = email_txt.text;
email_lv.subject_txt = subject_txt.text;
email_lv.message_txt = message_txt.text;
/* Finally, send the data to the server and get a response.
As mentioned above, serverlang holds the file extendion for
the server side language. You can hard code the complete file name. */
email_lv.sendAndLoad("cgi-bin/SendMail.cgi", email_lv, "POST");
}
};
And here's the .cgi script. I altered the opening line (to match the shebang on a script created by the isp) and the ToEmail line, and put the subparse.lib in the cgi-bin with the cgi script:
#!/usr/bin/perl -w
require "subparse.lib";
&Parse_Form;
$theMail = $formdata{'email_txt'};
$theSubject = $formdata{'subject_txt'};
$theMessage = $formdata{'message_txt'};
$ToEmail = "
[email protected]";
$ToSubject = $theSubject;
$EmailBody = $theMessage;
open (MAIL, "|/usr/sbin/sendmail -t") || &ErrorMessage;
print MAIL "To: $theMail \nFrom: $theMail\n";
print MAIL "Subject: $theSubject\n";
print MAIL "$theMessage\n";
close (MAIL);
print "Content-type: text/html\n\n";
Print "server_mes=ok";
sub ErrorMessage {
print "server_mes=Fail";
exit; }
I've tested your Flash form with the script created by the isp, and it works as far as getting the data sent in an email. But it doesn't allow me to create a thankyou/success screen, and if the submit button is pressed more than once, subsequent emails come in with a lot of html as well as the text from the thank you screen i created with the isp's wizard. I'd like to be able to edit and troubleshoot this myself, but the isp's script is extremely long and beyond me.
Thanks for your quick response and any help you can offer!