PDA

View Full Version : Flash form and cgi


Skarab
03-26-2008, 07:49 PM
I'm creating a Flash form for making reservations online. I thought I would be using php, then found that my client's hosting package doesn't allow php, so I'm using cgi.

What I'm trying to determine is whether I need to give all the input fields variable names, since the field names don't seem to be referenced in the cgi script.

I've looked at a number of tutes but can't seem to find a definitive answer.

I'd also like to know if there are any other things I *should* know about working with Flash and cgi that don't get mentioned in the tutes!

Thanks for any help!

Skarab
03-27-2008, 06:05 PM
Okay, I'm making progress on this problem. I'm now trying the cgi FormMail script from Matt's Script Archive and it's kinda sorta working.

What I need to know is how to put the equivalent of a "hidden" input field in the ActionScript for the recipient email address. the cgi script doesn't have a place for an explicit recipient though you can specify what domains are allowed. So I'm guessing the recip name(s) need to be in the AS, just not sure how to syntax it.

Skarab
04-03-2008, 10:04 PM
Well it turns out I can't use cgi for this as my client's website is on a Windows server, so I've turned to asp. I've got a script that is working except that I can't get the form data to populate the body of the email. Subject and to and from work fine, but the email body is blank. Here's the script I've been working with:

<%
dim fromEmail, toEmail, thesubject, themessage, i

'Gets the incoming variables from flash
fromEmail = Request.form("fromEmail_txt")
'toEmail = Request.form("toEmail_txt")
'thesubject = Request.form("subject_txt")
firmname = Request.form("firmName_txt")
checkin = Request.form("checkIn_txt")

'strName = "Gerry Mooney"
strEmail = "gmooney@visualexllc.com"
strSubject = "LegalPads Reservation Request"
strBody = firmname & checkin


'Declare and create email object
dim objmail

set objmail = Server.CreateObject("CDO.Message")
'error handler, if error encountered, ignore it and proceed
On Error resume next

'build the email using the variables from flash
objmail.From = fromEmail
objmail.To = (strEmail)
objmail.Subject = (strSubject)
objmail.Body = strBody
objmail.Send
'error handler, if error encountered, ignore it and proceed
On Error resume next

'If any errors were encounter then run this code
If Err.Number <> 0 then
'tells flash ASP failed and terminates the ASP file.
Response.Write "&server_mes=fail"
Response.End
else
'Send message back to flash saying everything was ok.
Response.Write "&server_mes=ok"
End if

%>


I think the problem is in the way the "firmname" and "checkin" are passed to the strBody variable, but I can't seem to see what's wrong with it. I've tried a number of different combinations and fleld names, but nothin so far. Any suggestions are appreciated!

tg
04-03-2008, 10:14 PM
whats your as look like that sends the data to your asp page?

Skarab
04-03-2008, 10:45 PM
Looks like this here:

//Create a loadvars object named email_lv
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 (this.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 (!fromEmail_txt.length || fromEmail_txt.indexOf("@") == -1 || fromEmail_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 (!firmName_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.fromEmail_txt = fromEmail_txt.text;
email_lv.subject_txt = subject_txt.text;
email_lv.firmName_txt = firmName_txt.text;
email_lv.checkIn_txt = checkIn_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("SendMail_mytest.asp", email_lv, "POST");
}
};

Skarab
04-07-2008, 02:17 PM
*bump* any help here would be appreciated!