Solved

Flash Form Processing

Posted on 2006-06-12
12
235 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
  • 7
  • 5
12 Comments
 
LVL 34

Expert Comment

by:Aneesh Chopra
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:socross
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 34

Expert Comment

by:Aneesh Chopra
Comment Utility
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
Comment Utility
thanks
0
 
LVL 1

Author Comment

by:socross
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now