Flash and PHP

  • Travis Coats
  • Graduate
  • Graduate
  • Travis Coats
  • Posts: 107

Post 3+ Months Ago

I know this has been beaten around a lot, but could comeone tell me how I can get PHP code to mail Flash form variables to my account. I have Bluehost and it has "Bluemail" and everytime I experiment with it, it always fails. I had it sending mail for a while, but it wans't sending it with the common Bluemail sender block all the time it would sometimes be something like allinnia229boxetc. Then it would quit all together. I had someone tell me that the varaible names could not be made up i.e. "favoritetrack, "music." Since Bluehost uses the variable name guidelines of Name, Zip, Phone, and all that jazz. Every tutorial I come across does not use checkboxes or dropdowns, only text fields.

I need the PHP to send checkbox and dropdown selections. I need to convert this page's form to a flash menu on the main page and get rid of this page. (http://www.allinnia.com/critique.html) Maybe that will help your answer better. If you tell me to find a script on the forum please post a link to it, this forum is full of seemingly similar questions with either no answer or nothing similar to what i am asking.

Thanks
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

If you're looking for the exact code, then you can skip reading this post. If you want to learn how to send an email, then go on with the reading.

step 1:
learn to use Flash UI components (plenty of tutorials on the net) -> combo box and radio box
step 2:
learn how to use LoadVars class -> see actionscript help for "send" and "sendAndLoad" methods which belong to LoadVars
step3:
learn about a simple example for "mail" function in php (also plenty of examples on the net)
step4: come back here and tell us your impressions.
  • Travis Coats
  • Graduate
  • Graduate
  • Travis Coats
  • Posts: 107

Post 3+ Months Ago

I love you and everything but come one. I have already read the tutorials. I have contacted Bluehost to ask why the form sends only a few times and then not others. Specifically, the working form works fine on my Mac, when I export the movie I recieve the email upon completing the form. However, when I upload it to the server it says waiting for bluehost in the browsers bottom tab forever. I don't think it is the code, but I know something is wrong. I am not experienced enough in PHP to catch it right now. That is why I asked you.
  • Travis Coats
  • Graduate
  • Graduate
  • Travis Coats
  • Posts: 107

Post 3+ Months Ago

I decided to get more specific here since most of the "gurus" never seem to assume much other than questions posted are questions posted by idiots.

I have all my form elements, i.e. input text field with variables assigned to them that are compatible with my servers CGI script, on the root time line. I decided not to put them in a movie-clip for my own simplistic reasons(not that it matters). The variables that are what HTML would consider "hidden" are defined in the first layer of my actionscript timeline:

stop();
var sendtoemail = "travis@allinnia.com";
var subject = "Website Critique";
var Text = "1";
var enctype = "multipart/form-data";

Then once the required fields are filled in, the variables stored as text strings are submitted by an on (release) button actionscript which is here:

on (release){
loadVariables("http://www.bluehost.com/bluemail","_root","POST");
gotoAndStop("sent");
}

This works fine on MY computer, but upon loading to the server I get this:

http://www.allinnia.com/test.html

I was a little offended by ICE's response since if I am asking this on a forum, I would have read and studied the area of concentration before looking like an idiot. I have contacted bluehost about this but they never have scripting advice, since it is not their area of understanding. My confusion lies in the fact that it emails fine from home on the tested .swf, but on a server it gets what you can see above through the link. I know that a lot of people have flash forms on their servers, but no one on bluehosts forums have anything like this. Help please.
:(
  • dhonsvick
  • Beginner
  • Beginner
  • dhonsvick
  • Posts: 49

Post 3+ Months Ago

here would be my approach.... and I am sure you tried this

1) Hmm bluehost hadnt heard of it. I did try your example here. Also Tried the send and load example .. Seemed to work and return a status.

However I think what you are bumping into is Flash CrossDomain Security. It works from the flash player within flash directly but when you upload to your server it becomes and issue of Cross domain security. the other doamin needs to have a fle called crossdomain.xml with the following format in order for flash to be allowed to do this. Bluehost would have to host this file. You would have to point to a middle man "PHP" to resend the variables to get around this.




Code: [ Select ]
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy
 SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
 <allow-access-from domain="*.yourdoamin.com" />
<!-- this could also be a wildcard for any domain //-->
</cross-domain-policy>
  1. <?xml version="1.0"?>
  2. <!DOCTYPE cross-domain-policy
  3.  SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
  4. <cross-domain-policy>
  5.  <allow-access-from domain="*.yourdoamin.com" />
  6. <!-- this could also be a wildcard for any domain //-->
  7. </cross-domain-policy>
  • Travis Coats
  • Graduate
  • Graduate
  • Travis Coats
  • Posts: 107

Post 3+ Months Ago

Thanks, for that information. I bookmarked that adobe tech note! It makes sense now, before I couldn't wrap my mind around why it works functionally from my home cpu, but when uploaded it does nothing but wait indefinitely(status waiting for bluehost.com etc.). I will email bluehost about this, I would think they should host such a file, in the case that someone using their service would need/want a flash form to mail through their CGI interface. With PHP, there are a number of other issues , that I, as a non-programming type would hate to encounter. Security is a big one, and my faulty coding could allow spammers to hit my bandwidth hard. I am also at a lack to find a working PHP-mail script and I have downloaded 3 different, supposedly working, scripts and I can't seem to get them working. I would show you an example but I deleted them. I used to have the loadVariables command, posting the variables to a file named email.php, but most of the time it returned an error in the output panel saying:"error opening email.php".

This is frustrating, mainly because it seems to be so easy, but yet I have been working on it for months, I have even looked into ruby/perl/asp mailers instead but they make php look like child's play.(especially perl). Thanks again for the advice I will see what else I can find out.
  • dhonsvick
  • Beginner
  • Beginner
  • dhonsvick
  • Posts: 49

Post 3+ Months Ago

the only issue with using this bluehost CGI mailer is it requires you to put YOUR email address as a perameter in the Form ... this means that CGI form cant be used to spam others but it does endanger your email address for getting picked up by spammers.

Anyone with the right software can decompile a SWF to get your email, in the HTML form mode anyone can view source. Just pointing out security issues.

with so many abusers email is always a pain.

perhaps putting this as email.php on your server an using sendandLoad.

<?php
$to = 'myemail@example.com';
$subject = $_POST["subject"];
$message = $_POST["message"];
$headers = 'From: mysenderemail@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
print "message=sent";
?>

this way your email address is physically unavalable in any client side scripts. And the worst that can happen is someone can send YOU email through your script.
  • Travis Coats
  • Graduate
  • Graduate
  • Travis Coats
  • Posts: 107

Post 3+ Months Ago

<?php

$to = 'myemail@example.com';

True, as I said I am new to this. As for your script, thanks and could I add this?


$subject = $_POST["subject"];
$message = $_POST["message"];
$headers = 'From: $_POST["email"]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
print "message=sent";
?>

also if I wanted to add more than one POST variable into the message content, what is the syntax for doing that?

$subject = $_POST["subject"];
$message = $_POST["message"] + $_POST["favoriteTrack"];<---is this acceptable?-->
$headers = 'From: $_POST["email"]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
print "message=sent";
?>

That way I can include the email form field as the return address. I am going to give it a go. Thanks for all your help, you have been very patient, and I think you solved my problem.
  • dhonsvick
  • Beginner
  • Beginner
  • dhonsvick
  • Posts: 49

Post 3+ Months Ago

sure thing, cool site btw
  • Travis Coats
  • Graduate
  • Graduate
  • Travis Coats
  • Posts: 107

Post 3+ Months Ago

I thought this would be an easy fix, but I was wrong. Since last posting I gave up on php and moved to Cold fusion, and now I am back at Php. I am getting absolutely nothing.


Here is the code for Flash and Php:

stop();

//----------------<LoadVars>------------------\\

var myLoadVars:LoadVars = new LoadVars();
receive_lv.onLoad = function(success:Boolean){
if(success){
myText_txt.text = "Thank You";
gotoAndPlay("sent")
}
gotoAndPlay("error")
}

//----------------</LoadVars>------------------\\



this.invisible_Btn.onRelease = function () {
gotoAndPlay(main);
}

//----------------<Submit Button>------------------\\

this.contactForm.submit_btn.onRelease = function () {
trace("Button is working");
if (contactForm.name_txt.text == "" || contactForm.email_txt.text == "" || contactForm.comments_txt == "") {
gotoAndPlay("error");
trace("Error page working")
} else {
myLoadVars.Name = contactForm.name_txt.text;
myLoadVars.Email = contactForm.email_txt.text;
myLoadVars.Comments = contactForm.comments_txt.text;
myLoadVars.Track = contactForm.track_cb.selectedItem.label
//myLoadVars.sendtoemail = Sendtoemail;
// myLoadVars.redirect = Redirect;
//myLoadVars.subject = Subject;
trace(myLoadVars.Name);
trace(myLoadVars.Email);
trace(myLoadVars.Comments);
trace(myLoadVars.Track);
myLoadVars.send("http://www.allinnia.com/email.php", "POST");
}
}



PHP:

<?php

$to = 'travis@allinnia.com';
$subject = 'Musical Critique';
$message = $_POST["$Name\n\n"];
$message = $_POST["$Email\n\n"];
$message = $_POST["$Comments\n\n"];
$message = $_POST["$Track\n\n"];
$headers = 'From: Allinnia.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

echo "success";

?>
This actually gets me a mail message with no content. The headers are correct, but the message is empty.
If you wanna see the flash in failure action....
http://www.allinnia.com/test.html
This my friends is garbage. :(
  • Travis Coats
  • Graduate
  • Graduate
  • Travis Coats
  • Posts: 107

Post 3+ Months Ago

I have heard people recommending the PEAR Mail and Mail Mime modules. I don't want to learn PHP. I am musician trying to get a flash form on my site of my own design. Does anyone know how these Pear modules are installed on a remote server? Or anything else about them in that case.

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 12 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.