Link to home
Start Free TrialLog in
Avatar of cbeaudry1
cbeaudry1

asked on

Flash Form and PHP Processing

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?
Avatar of sam85281
sam85281

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

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
Avatar of cbeaudry1

ASKER

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.
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
tried that and it still didn't work for some reason...
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
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...
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
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
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
ASKER CERTIFIED SOLUTION
Avatar of Billystyx
Billystyx

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.