PDA

View Full Version : Flash Form no passing variables to php...pasted code here..


Jenny
09-29-2002, 05:05 AM
I want to use a php script to send me results from a flash form from
my website I'm not having any problems with the flash itself, actually I've made plenty of forms with flash using cgi scripts to mail me results with
no problem. But when I try using a php script to do this all I receive is a blank email. The $mailto and $subject variables are hard coded in
the script. It's the variables from the swf file that are not being
read.
Note: Publishing as flash 5 and using PHP/4.1.2


Here's the code from my send button which resides on the same level as
my input text variables

on (release) {
if (!Email.length || Email.indexOf("@") == -1 ||
Email.indexOf(".") == -1) {
EmailStatus = "Please enter a valid E-mail address";
}

else if (!FirstName.length) {
EmailStatus = "Please Enter your name before Sending";
}

else if (!ToComments.length) {
EmailStatus = "Please enter some text in you message";
}

else {
loadVariablesNum ("mailform.php4", "0", "Post");
EmailStatus = "Sending...


Here's the simple version of my PHP script

<?

$ToEmail = "me@mydomain.com";

$ToSubject = "Test Mail";

$EmailBody = $FirstName.$Email.$ToComments;

$EmailFooter = "\nThis message was sent by: $FirstName";

$Message = $EmailBody.$EmailFooter;

mail ($ToEmail, $ToSubject, $Message);

Print "_root.Mail.EmailStatus=Complete - Your mail has been sent";

?>
Thanks for taking the time to read this
Jen

JerryScript
09-30-2002, 07:00 AM
Have you tried echoing your variables to insure they are being passed to the php page?

Wass it PHP4.1.2 that began using $var=_post['var']; and $var=_get['var']; to load url encoded variables?

Jerry

Jesse
10-01-2002, 02:35 PM
For the timebeing replace:
loadVariablesNum ("mailform.php4", "0", "Post");
// which you might want to change anyway to
loadVariablesNum ("mailform.php4", "0", "POST");
// although I doubt capitalization makes any diff, I've never checked in this case
with
getURL ("mailform.php4", "", "GET");
That will let you see which variables, if any are being passed to the PHP. If the variables are being passed then your PHP is stuffing up, else the Flash is the problem. If Flash is your problem, make sure yo u're invoking the getURL/loadVariables call from the same timeline the variables you want to send reside on, as GET and POST only send variables on the same timeline as the command they are in...
PS - Crossposting is discouraged but we don't blacklist you for doing it once :) I'm sure Billy was just mucking about. He's a champ.

Billy T
10-01-2002, 02:49 PM
me? mucking around? never!!! ;)

I was just saying what I say to all crossposters...if someone took offence then I apologise

Jesse
10-01-2002, 03:03 PM
That PS was in relation to another post where Jenny stated she thought maybe she wasn't going to be helped coz she crossposted, coz maybe we were annoyed. Was just ensuring she knew that's not how it goes here :) Group hug!

Billy T
10-01-2002, 03:08 PM
;)

Jenny
10-01-2002, 03:18 PM
Hi,
I do believe that my variables are indeed being passed to the php script.
I changed the action script from Loadvar..
to GetURL. When I submit/send I get a url with a reeeeally long name, in it amongst all the other things I can see my inputed Name, Email, and Comments...

Does this mean my flash is ok and that it is my PHP that is "mucking" up?

Thanks for the replies
Jen

Jesse
10-01-2002, 03:21 PM
Well it means that the variables you want to pass are being passed, so assuming you've used the same variable names in your PHP file, then yes, it seems to be a PHP problem.

Jenny
10-01-2002, 03:36 PM
But alas! What is the problem?
I mean the PHP mail bit seems to be working..I do recieve the emal.
The variable names are exactly the same...
What could it be? what could it be...
should I contact my isp? Which is BTW earthlink ...
PS
I changed post to POST in the VarNum line still nothing...

PSS, No offense taken on you moderators
just doing your job (Billy T) ;)

Ok group hugs back
Jen

Jesse
10-01-2002, 04:08 PM
Well you have to work backwards now. The email is obviously being sent, and it is blank, check if the variables $EmailBody and $EmailFooter ar eindeeed being sent by your Flash. They will be included in that huge URL you get using getURL if they are. If they are there and it still doesn't work, I can't think what it might be.

snipe
10-09-2002, 10:15 AM
It sounds to me as though register_globals in your php.ini file may be turned off. I wrote up a page that may help:

http://www.snipe.net/geek/toolz/globals.php

Arsenal
10-22-2002, 11:40 PM
Snipe is correct. I had the same problem as Jenny (client is hosted by earthlink) and the globals are disabled -- this seems to be the default for PHP4, a significant change since PHP3 (which is what the related tutorial refers to). Snipe, your page rocks.

Only problem is I can't see how to post multiple variables to the message using this new method (and the comma delimted file formatting outlined in the tutorial). This is probably a very simple issue. In the meantime I just have Flash create a new variable that combines all of the variables that I want to send via email and the PHP just sends that one variable as the message body.

snipe
10-22-2002, 11:44 PM
Hi Jenny/Arsenal - whats the file look like that passes the variable to Flash?

Arsenal
10-23-2002, 12:13 AM
<?php
mail("me@me.com", "Product Registration", $_POST['message'], "From: PHPMailer\nReply-To: $EMAIL\nX-Mailer: PHP/" . phpversion());
?>

'message' being the combined variables from flash, though this doesn't work so well in terms of formatting the message body. How would I add additional variables, text and formatting (just the /n actually) to the message body segment?

Thanx

snipe
10-23-2002, 12:35 AM
I should preface this with the statement that although I am very experienced with PHP, I am quite new to combining PHP anf Flash, so I'm not qoo% sure on how Flash munges info as its passed.

That said, what actually gets printed out from your Flash textarea? (copy and paste from a test mail if possible, so I can see what its doing)

snipe
10-23-2002, 12:36 AM
qoo%? Haha... err.. I meant 100% :D

Arsenal
10-23-2002, 04:28 PM
The code that I posted is probably of little help, as the $_POST['message'] is only trying to post one variable to the body of the email, which works fine. What I want to do is send more than one variable (along with some hard-coded text and carriage returns, if possible) in that message body area. However, I can't figure out the correct syntax for sending multiple variables using the superglobals method -- right now I can only figure out how to send just one variable.

This project is loosely based on the PHP mailer tutorial, which only specifies how to send one variable in the PHP as the message body. It's not a matter of which variables are being passed from the swf file, I've checked to make sure they are all being sent to the PHP.

Thanks for the help, I'm sure this is just a simple syntax issue...

snipe
10-23-2002, 09:50 PM
Have you tried concatenating the variables with line breaks? Like:

<?php
$email_msg = "You have been sent postcard!\n\n";
$email_msg .= "From: ". $_POST['from_name']."\n";
$email_msg .= "Message: ". $_POST['message'] ."\n\n";
$email_msg .= "Thank you for using our service!\n";
?>

I'm not really sure f this is what you mean, but this would allow you to pass $email_msg as the message, including line breaks and additional variables. (\n creates a new line)

Arsenal
10-24-2002, 12:51 AM
Yes, I see what you're doing. I tried it and it works perfectly.

Much thanks for all the help. :)

Pooh
02-20-2003, 03:16 PM
This is working for me, and I get the message variable.

<?php
mail("me@me.com", "Product Registration", $_POST['message'], "From: PHPMailer\nReply-To: $EMAIL\nX-Mailer: PHP/" . phpversion());
?>

But, when I added this so I could get more varialbes:

$email_msg = "You have been sent postcard!\n\n";
$email_msg .= "From: ". $_POST['from_name']."\n";
$email_msg .= "Message: ". $_POST['message'] ."\n\n";
$email_msg .= "Thank you for using our service!\n";

it woldn't work. Probably because I don't know where to put them? I tried a couple of differnt spots. Where do you insert them? Or, do I need to make changes in flash? Can you elaborate more on where to put this so I can get more variables? Do I need to have just one variable (message) coming out of flash? If so, how do I make the 3 variables go to one?

Thanks!

Cybermanzg
08-28-2006, 09:35 PM
I believe the issue maybe the way you have your PHP...
PHP recieves info using a POST method by creating varaibles that look like this:
$Email = $_POST['Email'];
$Firstname = $_POST['Firstname'];
etc...

So, this:
<?

$ToEmail = "me@mydomain.com";

$ToSubject = "Test Mail";

$EmailBody = $FirstName.$Email.$ToComments;

$EmailFooter = "\nThis message was sent by: $FirstName";

$Message = $EmailBody.$EmailFooter;

mail ($ToEmail, $ToSubject, $Message);

Print "_root.Mail.EmailStatus=Complete - Your mail has been sent";

?>
Should look like this:
<?
//this is to recieve the variables being posted from Flash
//and assign them to a PHP value
$FirstName = $_POST['FirstName'];
$Email = $_POST['Email'];
$ToComments = $_POST['ToComments'];
//end added section

$ToEmail = "me@mydomain.com";

$ToSubject = "Test Mail";

$EmailBody = $FirstName,$Email,$ToComments;

$EmailFooter = "\nThis message was sent by: $FirstName";

$Message = $EmailBody.$EmailFooter;

mail ($ToEmail, $ToSubject, $Message);

Print "_root.Mail.EmailStatus=Complete - Your mail has been sent";

?>


Also, I am not sure you can use Loadvars to send info to PHP only to retrieve info from PHP....anway that part is unknown to me might want to use the Client/Server Loadvars object and method instead.