Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • Last Modified:

Flash Form Processing

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
socross
Asked:
socross
  • 7
  • 5
1 Solution
 
Aneesh ChopraCommented:
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
 
socrossAuthor Commented:
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
 
Aneesh ChopraCommented:
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
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
socrossAuthor Commented:
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
 
socrossAuthor Commented:
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
 
socrossAuthor Commented:
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
 
Aneesh ChopraCommented:
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
 
socrossAuthor Commented:
thanks
0
 
socrossAuthor Commented:
the _self option opens a blank page in the current window,

is therany way to avoid opening a window???

thanks
0
 
Aneesh ChopraCommented:
try any one of the following:

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

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

0
 
Aneesh ChopraCommented:
or I thing this one work:

just completely remove the target parameter...

my_lv.send("/cgi-bin/email.php","POST");
0
 
socrossAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now