Solved

Flash Form Processing

Posted on 2006-06-12
12
244 Views
Last Modified: 2012-06-21
hi

i am creating my first form in flash, i am familiar with cgi from a few forms i have done in html using perl scripts that i have downloaded

I understand the principles of sending the script on the server the relevant information form my form, and have the resourses to write the action script for this.

I am struggling when it comes to the cgi/script itself, i hear lots of people sugesstion php but i am unsure how to go about doing it

I have
4 textinput fields
3 comboboxs
1 text area
all with instance names
I want to email the results to 1 specific email address
i just need the script to recive them

can anyone help with writing the script or advise what i can do.

thanks
0
Comment
Question by:socross
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16890930
Hi,

I also suggest you should use php,

here is really nice tutorial with source files, on exactly what you want.

Flash-Based Email Form Using PHP
---------------------------------------
Tutorial: http://www.kirupa.com/developer/actionscript/flash_php_email.htm
source Files: http://www.kirupa.com/developer/actionscript/fla/Kirupa_flash_php_email.zip


Rgds
Aneesh
0
 
LVL 1

Author Comment

by:socross
ID: 16896705
thanks

have kinda got it working, i used component for my form so i defined the varibles in my action script

I have got the .php script working and flash talking to it (i think this is all fine)

But i havent got the results displaying in the email correctly,

Here is my php script:

<?php
$sendTo = "pepperton@dsl.pipex.com";
$subject = "SOCROSS Enquiry Form Submission";

$headers = "From: " . $_POST["name"];

$headers = "<" . $_POST["email"] . "\r\n";

$headers .= "Reply-To: " . $_POST["email"] . "\r\n";

$headers .= "Return-path: " . $_POST["email"];

$message = $_POST["name"];

$message = $_POST["tel"];

$message = $_POST["enquiry"];

$message = $_POST["week"];

$message = $_POST["day"];

$message = $_POST["phone"];

$message = $_POST["where"];

mail($sendTo, $subject, $message, $headers);

?>


and my action script for the button:


submit_btn.onRelease = function  () {
      var my_lv:LoadVars = new LoadVars ();
      
      my_lv.name = name.text;
      my_lv.email = email.text;
      my_lv.tel = tel.text;
      my_lv.enquiry = enquiry.text;
      my_lv.where = where.text;
      
      if(name.text != "" & email.text!= "")
      {
      my_lv.send("/cgi-bin/email.php","_blank","POST");
      gotoAndStop("success");
      }
      else
      {
      gotoAndStop("error")
      }
}


My problem lies in displaying the properties in the message content,,

i want name, tel, email, enquiry, where and then the results from the 3 combo boxes week, day and phone
all to display in the message content.

(do i deal with them combo-boxes differently i havent put the varibles for these into my actionscript yet.)

What do you recon?

Thanks


0
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 300 total points
ID: 16899050
few issue in your code....

1.
to read combo selected label..

you following code:
---------------
myCombo.selectedItem.label;
-------------

2.
whatever variables you want to send, all should be added in postVariable
for example:
-----------
submit_btn.onRelease = function  () {
     var my_lv:LoadVars = new LoadVars ();
     
     my_lv.name = name.text;
     my_lv.email = email.text;
     my_lv.tel = tel.text;
     my_lv.enquiry = enquiry.text;
     my_lv.where = where.text;
     my_lv.week = combo1.selectedItem.label;
     my_lv.day = combo2.selectedItem.label;
     my_lv.year = combo3.selectedItem.label;
     
     if(name.text != "" & email.text!= "")
     {
     my_lv.send("/cgi-bin/email.php","_blank","POST");
     gotoAndStop("success");
     }
     else
     {
     gotoAndStop("error")
     }
}
---------
(IMPORTANT: change combo instnace name as you have in actual)


3.
you should read variable properly using similar variable name as you sent it from flash...
secondly, I noticed in you php code, you are actually overwriting $message variable instead of concating....

here I try to fix you code:
------------
<?php
$sendTo = "pepperton@dsl.pipex.com";
$subject = "SOCROSS Enquiry Form Submission";

$headers = "From: " . $_POST["name"]. "\r\n";

$headers .= "<" . $_POST["email"] . "\r\n";

$headers .= "Reply-To: " . $_POST["email"] . "\r\n";

$headers .= "Return-path: " . $_POST["email"];

$message = $_POST["name"] . "\r\n";

$message .= $_POST["tel"] . "\r\n";

$message .= $_POST["enquiry"] . "\r\n";

$message .= $_POST["week"] . "\r\n";

$message .= $_POST["day"] . "\r\n";

$message .= $_POST["phone"] . "\r\n";

$message .= $_POST["where"];

mail($sendTo, $subject, $message, $headers);

?>
-------------


I tried fixing code as per my assumption using providing details,
if you still not able to fix it.
I suggest that please upload the fla and php file, I will fix it for you

Rgds
Aneesh
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 1

Author Comment

by:socross
ID: 16900265
brilliant

thanks for the reply,i am away for a couple of days now so wont have time to implement this untill i get back (thursday), when i get it implemented i will get back to you,

thanks
again

0
 
LVL 1

Author Comment

by:socross
ID: 16916698
hi

1)


got  the code working now but there is something i dont understand

could you fully explain what this bit of code does:



$headers = "From: " . $_POST["name"]. "\r\n";

$headers .= "<" . $_POST["email"] . "\r\n";

$headers .= "Reply-To: " . $_POST["email"] . "\r\n";

$headers .= "Return-path: " . $_POST["email"];



In my outlook i get the name displayed in the from bit but i cant reply to it

the reply-to and return-path just display in the top of the message.

2)

Is it possible to code an auto reply to the email account that submits the enquiry on the form.??


3)

Also i have another question to ask regarding formatting of the components in my form, can you help, should i post it as a new question.



Thanks
0
 
LVL 1

Author Comment

by:socross
ID: 16916720
4)

sorry forgot to ask

in the line of action script which calls the php script

what can i say to stop a new browser window opening,

instead of _blank

thanks



0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16917019
1.
this code is creating a PHP variable $headers and appending data in it..
which is being sent as header of mail...

2.
Auto-reply can be done using any auto reply software, but that does not have to do with anything this code..


3.
yes, regarding any new requirement, you should post a new question..

4.
To avoid opening new window,

use it as:
------------
my_lv.send("/cgi-bin/email.php","_self","POST");
---------
0
 
LVL 1

Author Comment

by:socross
ID: 16919827
thanks
0
 
LVL 1

Author Comment

by:socross
ID: 16923179
the _self option opens a blank page in the current window,

is therany way to avoid opening a window???

thanks
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16925163
try any one of the following:

------------
my_lv.send("/cgi-bin/email.php","","POST");
---------

------------
my_lv.send("/cgi-bin/email.php","_parent","POST");
---------

0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16925169
or I thing this one work:

just completely remove the target parameter...

my_lv.send("/cgi-bin/email.php","POST");
0
 
LVL 1

Author Comment

by:socross
ID: 16926575
i cant seem to work around

all the above options either open a new window with a blank browser window or a blank window in the current window

any suggestions??

thanks
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question