[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Flash Form and PHP Processing

Posted on 2005-05-11
14
Medium Priority
?
212 Views
Last Modified: 2010-04-03
I've got a flash movie with a form that works fine with ASP for email processing but need to port it to PHP. I've tried doing this but the form simply won't send the data.

Here's the actionscript in the Flash movie:

on (release) {
      
      if (!rname.length) {
            info = "Please enter your name.";
      }
      
      else if (!raddress.length) {
            info = "Please enter your address.";
      }
      
      else if (!rcity.length) {
            info = "Please enter your city of residence.";
      }
      
      else if (!rstate.length) {
            info = "Please enter your state.";
      }
      
      else if (!rzip.length) {
            info = "Please enter your zip code";
      }
      
      else if (!rphone.length) {
            info = "Please enter your phone number";
      }
      
      else if (!remail.length || remail.indexOf("@") == -1 || remail.indexOf(".") == -1) {
            info = "Please enter a valid e-mail address.";
      }  
      
      else if (!cardnumber.length) {
            info = "Please enter your credit card number.";
      }
      
      else if (!expdate.length) {
            info = "Please enter your card's expiration date.";
      }
      
      else {
            team1.setData("82nd Airborne");
            team2.setData("Special Forces");
            team3.setData("Navy Seals");
            team4.setData("N.V. Army");
            team5.setData("V.C. Guerillas");
            team6.setData("Hunter Teams");
            teamsel = team.getValue();
            trace(camp.getValue());
            if (camp.getValue() == true){
            campsel = "Yes";
            }
            else {
            campsel = "No";
            }
            trace(specops.getValue());
            if (specops.getValue() == true){
            sosel = "Yes";
            }
            else {
            sosel = "No";
            }
            ccv.setData("Visa");
            ccm.setData("Master Card");
            card = CreditCard.getValue();
            loadVariablesNum ("regmail.php", "0", "POST");
        gotoAndPlay(651);
      }
}

And here's the PHP Mailer script:

<?PHP

$doMail = $_REQUEST['emailReply'];

$useremail = $_POST['remail'];
$subject = "Online Registration";

$Recipient = "emailaddress@sbcglobal.net";
$Sender = $remail;

$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];

$from_address  =
nl2br(htmlspecialchars($_POST['rname'],ENT_QUOTES));
$from_address .= " <";
$from_address .=
nl2br(htmlspecialchars($useremail,ENT_QUOTES));
$from_address .= ">";

$email_message = "";
$email_message .= "The following registration was sent through the XXXXXXXXX.com website. \n\n";
$email_message .= "The following information was provided.\n";
$email_message .= "" . $_POST['rname'] . "\n";
$email_message .= "" . $_POST['raddress'] . "\n";
$email_message .= "" . $_POST['rcity'] . ", " . $_POST['rstate'] . " " . $_POST['rzip'] . "\n";
$email_message .= "Phone: " . $_POST['rphone'] . "\n";
$email_message .= "Email: " . $_POST['remail'] . "\n\n";
$email_message .= "REGISTRATION ORDER\n\n";
$email_message .= "Team Selected: " . $_POST['teamsel'] . "\n";
$email_message .= "Camping: " . $_POST['campsel'] . "\n";
$email_message .= "Special Ops: " . $_POST['sosel'] . "\n";
$email_message .= "Paint Cases: " . $_POST['casetot'] . "\n";
$email_message .= "Short Sleeve Shirts: " . $_POST['sslab'] . "\n";
$email_message .= "Long Sleeve Shirts: " . $_POST['lslab'] . "\n";
$email_message .= "ORDER TOTAL: " . $_POST['total'] . "\n";
$email_message .= "CC Name: " . $_POST['card'] . "\n";
$email_message .= "CC Number: " . $_POST['cardnumber'] . "\n";
$email_message .= "CC Exp Date: " . $_POST['expdate'] . "\n\n";

$tab_content = date("j F Y, g:i a");
$tab_content .= "\t";
$tab_content .= $REMOTE_ADDR;
$tab_content .= "\t";

$headers  = "";
$headers .= "From: $Sender\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();

mail($Recipient, $subject, $email_message, $headers);

?>


Anyone have any idea where I'm going wrong?
0
Comment
Question by:cbeaudry1
  • 4
  • 4
  • 4
12 Comments
 
LVL 16

Expert Comment

by:sam85281
ID: 13983869
Your data in your email_message var is formatted wrong.

Example: $email_message .= "" . $_POST['rname'] . "\n"; should be: $email_message .= "$_POST['rname']\n";

Your variable goes INSIDE of the quotes.

Another example: $email_message .= "Email: " . $_POST['remail'] . "\n\n"; should be: $email_message .= "Email: $_POST['remail']\n\n";

-Sam

0
 
LVL 16

Expert Comment

by:sam85281
ID: 13983888
Going back through it, found some misc. stuff here and there.  Here's the complete script with all the formatting fixed:

I went through it quick, but pretty sure I caught it all, if it still doesn't work let me know.

<?PHP

$doMail = $_REQUEST['emailReply'];

$useremail = $_POST['remail'];
$subject = "Online Registration";

$Recipient = "emailaddress@sbcglobal.net";
$Sender = $remail;

$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];

$from_address  =
nl2br(htmlspecialchars($_POST['rname'],ENT_QUOTES));
$from_address .= " <";
$from_address .=
nl2br(htmlspecialchars($useremail,ENT_QUOTES));
$from_address .= ">";

$email_message = "";
$email_message .= "The following registration was sent through the XXXXXXXXX.com website. \n\n";
$email_message .= "The following information was provided.\n";
$email_message .= "$_POST['rname']\n";
$email_message .= "$_POST['raddress']\n";
$email_message .= "$_POST['rcity'], $_POST['rstate'] $_POST['rzip']\n";
$email_message .= "Phone: $_POST['rphone']\n";
$email_message .= "Email: $_POST['remail']\n\n";
$email_message .= "REGISTRATION ORDER\n\n";
$email_message .= "Team Selected: $_POST['teamsel']\n";
$email_message .= "Camping: $_POST['campsel']\n";
$email_message .= "Special Ops: "$_POST['sosel']\n";
$email_message .= "Paint Cases: $_POST['casetot']\n";
$email_message .= "Short Sleeve Shirts: $_POST['sslab']\n";
$email_message .= "Long Sleeve Shirts: $_POST['lslab']\n";
$email_message .= "ORDER TOTAL: $_POST['total']\n";
$email_message .= "CC Name: $_POST['card']\n";
$email_message .= "CC Number: $_POST['cardnumber']\n";
$email_message .= "CC Exp Date: $_POST['expdate']\n\n";

$tab_content = date("j F Y, g:i a");
$tab_content .= "\t";
$tab_content .= $REMOTE_ADDR;
$tab_content .= "\t";

$headers  = "";
$headers .= "From: $Sender\r\n";
$headers .= "X-Mailer: PHP/" . phpversion();

mail("$Recipient", "$subject", $email_message, $headers);

?>

-Sam
0
 

Author Comment

by:cbeaudry1
ID: 13993111
Hmmmm...It was processing the form before but took a while get to my email. The values weren't passed through though. I'll try a few more things to see if it makes a difference since now, it just doesn't process at all.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:sam85281
ID: 13993243
Try taking the quotes back off of mail("$Recipient", "$subject", $email_message, $headers);

Make it: mail($Recipient, $subject, $email_message, $headers);

The other changes I made above will fix the variables not going through problem, but I might have created the not sending problem by adding the quotes to the mail() function.

-Sam
0
 

Author Comment

by:cbeaudry1
ID: 14000780
tried that and it still didn't work for some reason...
0
 
LVL 16

Expert Comment

by:sam85281
ID: 14000800
Hmmm,  I must be missing something small and dumb. :)

I'll go through it line by line tonight and fugure it out.  Is not sending at all, or just not sending all the variables?

-Sam
0
 

Author Comment

by:cbeaudry1
ID: 14000823
At first, my original script wasn't sending the variables. The revised script isn't sending at all. I posted this from ASP and it was working fine "over there." It's the PHP that doesn't work for some reason. Permissions are set right. The script just isn't doing its' job even though it does look right...
0
 
LVL 18

Expert Comment

by:Billystyx
ID: 14009568
Try this...

$email_message = "";
$email_message .= "The following registration was sent through the XXXXXXXXX.com website. \n\n";
$email_message .= "The following information was provided.\n";
$email_message .= $_POST['rname']."\n";
$email_message .= $_POST['raddress']."\n";
$email_message .= $_POST['rcity'].",". $_POST['rstate']. $_POST['rzip']."\n";
$email_message .= "Phone:". $_POST['rphone']."\n";
$email_message .= "Email:". $_POST['remail']."\n\n";
$email_message .= "REGISTRATION ORDER\n\n";
$email_message .= "Team Selected:". $_POST['teamsel']."\n";
$email_message .= "Camping:". $_POST['campsel']."\n";


you had your posted variables inside quotes, if you continue like this, making sure all $_POST['variable'];
are outside ""

billystyx
0
 
LVL 18

Expert Comment

by:Billystyx
ID: 14009583
just read above posts, and realised that was what you had to start with!

But I have to say (with all due respect Sam:) I didn't think it could work your way - I have never formatted strings and variables like that.
I will have a look into it too:)

billystyx
0
 
LVL 18

Expert Comment

by:Billystyx
ID: 14009702
here, I found this example on the web at
http://www.phptr.com/articles/article.asp?p=29846&seqNum=4&rl=1



echo ("The month in question has ".$numberofdays." days in it.");

which leaves the variable name outside of the  string.

Perhaps the only difference here is that it is not the posted var inside the echo statement. Maybe you could try putting all your posted variables into their own variables at the top of the php script:

like:

 $rcity=$_POST['rcity'];
$rstate=$_POST['rstate'];
$rzip=$_POST['rzip'];
 

and then

$email_message .= $_POST['rcity'].",". $_POST['rstate']. $_POST['rzip']."\n";

as an example.

billystyx
0
 
LVL 18

Accepted Solution

by:
Billystyx earned 2000 total points
ID: 14035764
and in your flash, use
loadVariablesNum ("regmail.php", "", "POST");

and make sure all the variable names you are posting are the same variable names you try to pick up in php. (And on closer inspection, stick with your original script (or the one I changed it back to from Sam's - if you echo the variables in his version instead of mailing them, you will probably see that it doesn't provide info from flash.
As well, for troubleshooting, if you echo your $_POST variables called at the start of the php doc instead of mailing (and call the php doc directly (by typing into browser window and opening)
you will find at least one of them which doesn't have anything in the value for the variable name.

If that is the case, the vars are not leaving flash, or not being picked up by the correct name once they reach the php doc.

Let me know which:)

billystyx
0
 

Author Comment

by:cbeaudry1
ID: 14042606
Sorry I haven't posted in the last few days. I've been swamped with a couple of other projects. I will, however, implement these changes this weekend to see if it will solve the problem. I'm still following this thread. Just haven't had time to implement the solutions yet.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
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.
Suggested Courses

834 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