0
getting PHP to communicate with FLASH
New Here
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/td-p/628621
Feb 19, 2007
Feb 19, 2007
Copy link to clipboard
Copied
Im having some issues getting my flash contact form to
communicate with my form.PHP I have been scouring tutorials but im
just not getting what exactly goes into the PHP file. My variables
are different from the tutorials I have seen. This is what I have
I guess my main question is how do I set up the PHP file so that it can work with my flash files?
I guess my main question is how do I set up the PHP file so that it can work with my flash files?
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628622#M15144
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
em_shomer wrote:
> I guess my main question is how do I set up the PHP file so that it can work
> with my flash files?
Go to my site at http://foundationphp.com/flash/index.php
Download the free sample chapter. It covers exactly what you're looking for.
--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
> I guess my main question is how do I set up the PHP file so that it can work
> with my flash files?
Go to my site at http://foundationphp.com/flash/index.php
Download the free sample chapter. It covers exactly what you're looking for.
--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
em_shomer
AUTHOR
New Here
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628623#M15145
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
I dont have the book or software so I am doing this on my
main project:
I basically cut and pasted the code to frame 1 because I dont have a load date variable so everything resides on Frame 1
I get several output errors:
***ERROR*** frame 1 line 2 ' { ' expected
function checkForm() :Boolean {
**ERROR** frame=1 line 26:
unexpected ' } ' encountered
}
how do I handle this so I dont get these error messages
I basically cut and pasted the code to frame 1 because I dont have a load date variable so everything resides on Frame 1
I get several output errors:
***ERROR*** frame 1 line 2 ' { ' expected
function checkForm() :Boolean {
**ERROR** frame=1 line 26:
unexpected ' } ' encountered
}
how do I handle this so I dont get these error messages
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Enthusiast
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628624#M15146
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
Below is my contact form code. It works beautifully. You may
have to modify it some to achieve your ultimate goal but it is very
simple and easy to understand.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
em_shomer
AUTHOR
New Here
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628625#M15147
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
Ok im beyond frusterated here nothing seems to be working. I
have gone back to my originial contact form:
I need help because I have been doing this for 8 hours straight and its not working Since im following several tutorials can someone explain to me by looking at my code,
!) What is my Variable? (is it visitor_comments or userMessage.text?) are variables the same as Instance names because in this case the instance name is userMessage
2) How do I define the Variables since i obviously havent defined it or else it would be working?
3 How do i denote the variables in PHP
I know i am probably making this harder than it is, but im such a noob and I dont have time to learn actionscript and PHP
I need help because I have been doing this for 8 hours straight and its not working Since im following several tutorials can someone explain to me by looking at my code,
!) What is my Variable? (is it visitor_comments or userMessage.text?) are variables the same as Instance names because in this case the instance name is userMessage
2) How do I define the Variables since i obviously havent defined it or else it would be working?
3 How do i denote the variables in PHP
I know i am probably making this harder than it is, but im such a noob and I dont have time to learn actionscript and PHP
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Enthusiast
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628627#M15149
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
variables in php are denoted by the $ symbol. they may or may
not include a var before them to handle scope. generally, you'd
want to post the php file with your questions. It will make it
easier on all of us to help you. If you can, post the php file and
we can tell you how to set up your movie to get what it is that you
want.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628633#M15155
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
em_shomer wrote:
> I dont have the book
You don't need the book. Download the sample chapter from the link on
that page. It's a free PDF file which gives step by step instructions
for what you're trying to do.
--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
> I dont have the book
You don't need the book. Download the sample chapter from the link on
that page. It's a free PDF file which gives step by step instructions
for what you're trying to do.
--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628648#M15170
Feb 22, 2007
Feb 22, 2007
Copy link to clipboard
Copied
Thats a very insightful and appreciated chapter you have
online. Thanks for mentioning it as I am trying to learn the same
thing.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628626#M15148
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
noone can help you unless they are familiar with that php
script or they are willing to check that php script or you inform
us what variables it expects.
because it doesn't look like anyone is doing the first two why don't you tell us. almost certainly it is spelled out in the comments of that php script, at it beginning, what variables it needs. what are they?
because it doesn't look like anyone is doing the first two why don't you tell us. almost certainly it is spelled out in the comments of that php script, at it beginning, what variables it needs. what are they?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
em_shomer
AUTHOR
New Here
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628628#M15150
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
<?php
$eName=$_POST['visitor_name'];
$eEmail=$_POST['visitor_email'];
$subject = 'A Message from a Bodyshop client';
$eComments=$_POST['visitor_comments'];
$toaddress="my@email.com";
if(mail($toaddress,$subject,$message,"From: ".$name." <".$email.">")){
$Name='';
$Email='';
$subject='';
$Comm ='';
$Phone =";
echo "&response=passed";
} else {
echo "&response=failed";
}
?>
$eName=$_POST['visitor_name'];
$eEmail=$_POST['visitor_email'];
$subject = 'A Message from a Bodyshop client';
$eComments=$_POST['visitor_comments'];
$toaddress="my@email.com";
if(mail($toaddress,$subject,$message,"From: ".$name." <".$email.">")){
$Name='';
$Email='';
$subject='';
$Comm ='';
$Phone =";
echo "&response=passed";
} else {
echo "&response=failed";
}
?>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628629#M15151
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
there's no email_to. fix that in $toaddress.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
em_shomer
AUTHOR
New Here
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628630#M15152
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
i left my email out on purpose...
can you maybe or someone just explain how to set up the PHP form from my actionscript posted:
stop();
// -------------------<send form LoadVars>------------------- \\
var gatherForm:LoadVars = new LoadVars();
function sendForm() {
gatherForm.email_to = "eric.shomer@gmail.com";
gatherForm.visitor_comments = eComments.text;
gatherForm.visitor_name = eName.text;
gatherForm.visitor_email = eEmail.text;
gatherForm.visitor_phone = ePhone.text;
gatherForm.send("form.php", "POST");
}
// -------------------</send form LoadVars>------------------- \\
//--------------------<submit button AS>---------------------\\
// onRelease
submitBtn.onRelease = function() {
if (eEmail.text == "" || ePhone.text =="" || eName.text == "" || eComments.text == "") {
gotoAndStop("error");
} else {
sendForm();
gotoAndStop("correct");
}
}
//--------------------</submit button AS>---------------------\\
can you maybe or someone just explain how to set up the PHP form from my actionscript posted:
stop();
// -------------------<send form LoadVars>------------------- \\
var gatherForm:LoadVars = new LoadVars();
function sendForm() {
gatherForm.email_to = "eric.shomer@gmail.com";
gatherForm.visitor_comments = eComments.text;
gatherForm.visitor_name = eName.text;
gatherForm.visitor_email = eEmail.text;
gatherForm.visitor_phone = ePhone.text;
gatherForm.send("form.php", "POST");
}
// -------------------</send form LoadVars>------------------- \\
//--------------------<submit button AS>---------------------\\
// onRelease
submitBtn.onRelease = function() {
if (eEmail.text == "" || ePhone.text =="" || eName.text == "" || eComments.text == "") {
gotoAndStop("error");
} else {
sendForm();
gotoAndStop("correct");
}
}
//--------------------</submit button AS>---------------------\\
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628631#M15153
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
there should be nothing to setup except to be sure you swf
and your php script are in the same directory, your php is
receiving all the variable/values it expects and your php script
has permissions granted to be read and executed by everyone.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
em_shomer
AUTHOR
New Here
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628632#M15154
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
what im saying is: pretend I dont have a PHP script...by
looking at actionscript posted above. How would you set up the
PHP.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Enthusiast
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628634#M15156
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
Ok. I've included your code with a few additions.
First and foremost, whenever I'm sending data from a contact form, I always make sure to do something with the response so that I know first hand that the backend php communications are working. This is often times just a simple trace during testing to see what response was received by LoadVars.
Examining your AS, I noticed a few things.
First, you used mail.php as your file. If you are testing on the local system, this isn't going to work...not unless you have a PHP parser installed and running on your system when you are testing inside Flash. You need to rewrite the url and include the full URL to the file on the webserver i.e. www.mydomain.com/php/mail.php or whatever the url is for the mail.php file on your server.
Second, you are sending the user off to "correct" before you even know for sure that there was a successful communication with the mail.php file at all. I added a second LoadVars to your AS as well as changed the line gatherForm.send(...) to gatherForm.sendAndLoad(....). This way, you know for certain that the file in question (mail.php) is both legit, ready and working and you'll also know that you have received the data back from that file.
First and foremost, whenever I'm sending data from a contact form, I always make sure to do something with the response so that I know first hand that the backend php communications are working. This is often times just a simple trace during testing to see what response was received by LoadVars.
Examining your AS, I noticed a few things.
First, you used mail.php as your file. If you are testing on the local system, this isn't going to work...not unless you have a PHP parser installed and running on your system when you are testing inside Flash. You need to rewrite the url and include the full URL to the file on the webserver i.e. www.mydomain.com/php/mail.php or whatever the url is for the mail.php file on your server.
Second, you are sending the user off to "correct" before you even know for sure that there was a successful communication with the mail.php file at all. I added a second LoadVars to your AS as well as changed the line gatherForm.send(...) to gatherForm.sendAndLoad(....). This way, you know for certain that the file in question (mail.php) is both legit, ready and working and you'll also know that you have received the data back from that file.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
em_shomer
AUTHOR
New Here
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628635#M15157
Feb 20, 2007
Feb 20, 2007
Copy link to clipboard
Copied
still not working...but thanks for the effort...i officially
give up
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Enthusiast
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628636#M15158
Feb 21, 2007
Feb 21, 2007
Copy link to clipboard
Copied
What did you do based on my last post? No offense, but it's
not customary for us to write people step by step instructions for
everything. We assume that people have a pretty basic understanding
of the technology they wish to use. Getting aggravated because you
don't know php or actionscript isn't going to solve the problem.
And be specific.... What exactly is not working? Are you not getting the e-mail? Is it not going to the frame label you want? What are the instance names of each text field in the form? Do these match exactly to those in your sendForm function to be sent by LoadVars? Does your server support PHP and if so, does it allow mail()? This stuff all makes a huge difference. Have you tried to use the php file on it's own in an html form? If not, I'd try that first.
Another idea, post the fla file and the php file via zip. kglad, myself and others will gladly download it and look at it to see what if anything we notice. There may be other conflicts inside your fla file that are botching up the LoadVars etc that you may not see. A fresh set of eyes never hurts. Giving us the code many times is not going to be enough to give the clearest picture of the problem. We'd rather you learn than get frustrated and give up.
And be specific.... What exactly is not working? Are you not getting the e-mail? Is it not going to the frame label you want? What are the instance names of each text field in the form? Do these match exactly to those in your sendForm function to be sent by LoadVars? Does your server support PHP and if so, does it allow mail()? This stuff all makes a huge difference. Have you tried to use the php file on it's own in an html form? If not, I'd try that first.
Another idea, post the fla file and the php file via zip. kglad, myself and others will gladly download it and look at it to see what if anything we notice. There may be other conflicts inside your fla file that are botching up the LoadVars etc that you may not see. A fresh set of eyes never hurts. Giving us the code many times is not going to be enough to give the clearest picture of the problem. We'd rather you learn than get frustrated and give up.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
em_shomer
AUTHOR
New Here
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628637#M15159
Feb 21, 2007
Feb 21, 2007
Copy link to clipboard
Copied
Please understand it is very hard to communicate effectivly
in a message board when you are new to something I have a basic
understanding of the material, but i dont know anything about PHP,
hence the reason I am here. Anyway I would really like to get this
fixed and see what my mistake is. If anybody is willing to take a
look at it and help me out with it I would really appreciate it.
Furthermore If you are able to get it working I will be happy to
compensate for your troubles.
I am attaching a link to a zip file of the contact form, PHP and swf files.
link
I am attaching a link to a zip file of the contact form, PHP and swf files.
link
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628638#M15160
Feb 21, 2007
Feb 21, 2007
Copy link to clipboard
Copied
here's your correct file:
http://www.gladstien.com/Files/contact.zip
if you want to try it first: http://www.gladstien.com/Files/contactForm.html
if you want to try it first: http://www.gladstien.com/Files/contactForm.html
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
em_shomer
AUTHOR
New Here
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628639#M15161
Feb 22, 2007
Feb 22, 2007
Copy link to clipboard
Copied
Thanks for the help...I am still having a problem. I am able
to advance to the correct frame label, but nothing is happening. I
am not getting emails. Perhaps there is something either with my
email or on the server. I appreciate your help
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628640#M15162
Feb 22, 2007
Feb 22, 2007
Copy link to clipboard
Copied
is your email address correct in the php file? do you receive
an email when you test contactForm.html on the above site?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
em_shomer
AUTHOR
New Here
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628641#M15163
Feb 22, 2007
Feb 22, 2007
Copy link to clipboard
Copied
Well email is correct in PHP file as well as Flash File. I
would have liked to try it out on your site, but unfortunatly link
is broken
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Enthusiast
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628642#M15164
Feb 22, 2007
Feb 22, 2007
Copy link to clipboard
Copied
There were some issues in the original PHP file. I'm not sure
if you ever corrected those but they existed in the mail() line
which meant that the e-mail would never send. Below is the correct
php file. Just copy and paste and then insert your e-mail in the
correct line. Try it again, and get back to me.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628643#M15165
Feb 22, 2007
Feb 22, 2007
Copy link to clipboard
Copied
i corrected the php file and the swf.
the test link was missing a w so you can retest yourself with the obvious addition of the third w.
i also sent a test email using the contact form which you should receive sometime after 8:40am pst.
the test link was missing a w so you can retest yourself with the obvious addition of the third w.
i also sent a test email using the contact form which you should receive sometime after 8:40am pst.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
em_shomer
AUTHOR
New Here
,
/t5/animate-discussions/getting-php-to-communicate-with-flash/m-p/628644#M15166
Feb 22, 2007
Feb 22, 2007
Copy link to clipboard
Copied
Still no email. I am using the original PHP and Swf sent in
the zip file from last evening. I can still get to the frame label
that says the message was sent, but there is no email.
<?php
$to = "eric.shomer@gmail.com";
$name = $_POST['visitor_name'];
$email = $_POST['visitor_email'];
$message = $_POST['visitor_comments'];
$phone = $_POST['visitor_phone'];
$subject = 'A Message from a Bodyshop client';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From:'. $name .' <' . $email . '>' . "\r\n";
$ok = mail($to, $subject, $message, $phone, $headers);
if($ok) {
echo "&response=passed&";
} else {
echo "&response=failed&";
}
?>
SWF******
this.stop();
// -------------------<send form LoadVars>------------------- \\
var gatherForm:LoadVars = new LoadVars();
var receiveForm:LoadVars = new LoadVars();
receiveForm.onLoad = function() {
if (this.response == "passed") {
name_txt.text = "";
email_txt.text = "";
phone_txt.text = "";
msg_txt.text = "";
trace("email sent");
gotoAndStop("correct");
}
};
function sendForm() {
gatherForm.email_to = "eric.shomer@gmail.com";
gatherForm.visitor_comments = msg_txt.text;
gatherForm.visitor_name = name_txt.text;
gatherForm.visitor_email = email_txt.text;
gatherForm.visitor_phone = phone_txt.text;
// You may want to try the absolute http to this file i.e. http://www.mydomain.com/form.php
// If you are testing on the local system and it doesn't know how to parse php,
// you'll never get a response back from the file.
gatherForm.sendAndLoad(" http://www.bodyshopfitnesscenter.com/sources/Flash/form.php", receiveForm, "POST");
}
// -------------------</send form LoadVars>------------------- \\
//--------------------<submit button AS>---------------------\\
// onRelease
submitBtn.onRelease = function() {
if (email_txt.text == "" || phone_txt.text == "" || name_txt.text == "" || msg_txt.text == "") {
gotoAndStop("error");
} else {
sendForm();
}
};
//--------------------</submit button AS>---------------------\\
<?php
$to = "eric.shomer@gmail.com";
$name = $_POST['visitor_name'];
$email = $_POST['visitor_email'];
$message = $_POST['visitor_comments'];
$phone = $_POST['visitor_phone'];
$subject = 'A Message from a Bodyshop client';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From:'. $name .' <' . $email . '>' . "\r\n";
$ok = mail($to, $subject, $message, $phone, $headers);
if($ok) {
echo "&response=passed&";
} else {
echo "&response=failed&";
}
?>
SWF******
this.stop();
// -------------------<send form LoadVars>------------------- \\
var gatherForm:LoadVars = new LoadVars();
var receiveForm:LoadVars = new LoadVars();
receiveForm.onLoad = function() {
if (this.response == "passed") {
name_txt.text = "";
email_txt.text = "";
phone_txt.text = "";
msg_txt.text = "";
trace("email sent");
gotoAndStop("correct");
}
};
function sendForm() {
gatherForm.email_to = "eric.shomer@gmail.com";
gatherForm.visitor_comments = msg_txt.text;
gatherForm.visitor_name = name_txt.text;
gatherForm.visitor_email = email_txt.text;
gatherForm.visitor_phone = phone_txt.text;
// You may want to try the absolute http to this file i.e. http://www.mydomain.com/form.php
// If you are testing on the local system and it doesn't know how to parse php,
// you'll never get a response back from the file.
gatherForm.sendAndLoad(" http://www.bodyshopfitnesscenter.com/sources/Flash/form.php", receiveForm, "POST");
}
// -------------------</send form LoadVars>------------------- \\
//--------------------<submit button AS>---------------------\\
// onRelease
submitBtn.onRelease = function() {
if (email_txt.text == "" || phone_txt.text == "" || name_txt.text == "" || msg_txt.text == "") {
gotoAndStop("error");
} else {
sendForm();
}
};
//--------------------</submit button AS>---------------------\\
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more


-
- 1
- 2