Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-26-2008, 06:49 PM   #1
Skarab
Senior Member
 
Skarab's Avatar
 
Join Date: Jan 2005
Posts: 122
Default Flash form and cgi

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 is offline   Reply With Quote
Old 03-27-2008, 05:05 PM   #2
Skarab
Senior Member
 
Skarab's Avatar
 
Join Date: Jan 2005
Posts: 122
Default

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 is offline   Reply With Quote
Old 04-03-2008, 09:04 PM   #3
Skarab
Senior Member
 
Skarab's Avatar
 
Join Date: Jan 2005
Posts: 122
Default

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:

Code:
<%
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 = "[email protected]"
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!
Skarab is offline   Reply With Quote
Old 04-03-2008, 09:14 PM   #4
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

whats your as look like that sends the data to your asp page?
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 04-03-2008, 09:45 PM   #5
Skarab
Senior Member
 
Skarab's Avatar
 
Join Date: Jan 2005
Posts: 122
Default

Looks like this here:

ActionScript Code:
//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 is offline   Reply With Quote
Old 04-07-2008, 01:17 PM   #6
Skarab
Senior Member
 
Skarab's Avatar
 
Join Date: Jan 2005
Posts: 122
Default

*bump* any help here would be appreciated!
Skarab is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash 8 - form mail raimeyo ActionScript 2.0 0 11-09-2007 02:50 PM
Help with CGI form in Flash MX AlienDev211 ActionScript 2.0 0 10-29-2007 10:20 PM
how can i send my data from my form to my email? dina farouk ActionScript 2.0 0 04-08-2007 11:33 AM
Mail form using Flash Gordons coding tooviral ActionScript 2.0 15 03-18-2007 07:07 PM
cgi contact form dmx005 Server-Side Scripting 1 01-31-2007 05:01 PM


All times are GMT. The time now is 12:24 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.