Jump to content

ActionScript 3.0 and PHP


Myth of Echelon

Recommended Posts

Okay, so for a college assignment I need to make a website (which is done and dusted). This website contains a questionnaire so that users can anonymously submit feedback regarding the website. Originally, it was pseudo-functional - you could input text, click checkboxes and clear all data to start again but that's it. Variable stores were cleared as soon as the frame was exited. Today, I decided to add coding so that results could actually be emailed to me from within the Flash application - the SWF.

 

Apparently, there is already a .php file hosted at "http://www.actionscript.tv/email.php"'>http://www.actionscript.tv/email.php" (as stated within a Flash lesson file and an official Flash AS3 book I bought). I am currently using this to try and successfully submit a basic email.

The coding inside this .php file is:

"<?php

 

$sendTo = $_POST["sEmail"];

 

$subject = $_POST["sSubject"];

 

$headers = "From: " . $_POST["sName"] . "<" . $_POST["sEmail"] .">\r\n";

 

$headers .= "Reply-To: " . $_POST["sEmail"] . "\r\n";

 

 

$headers .= "Return-path: " . $_POST["sEmail"];

 

 

 

$message = $_POST["sMessage"];

 

 

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

 

?>"

 

 

and my ActionScript 3 coding is:

 

"import flash.net.URLVariables;

import flash.net.URLRequest;

import flash.events.Event;

 

var note:String;

var now:Date = new Date();

var variables:URLVariables = new URLVariables();

var mailAddress:URLRequest = new URLRequest("http://www.actionscript.tv/email.php");

 

subButton.addEventListener(MouseEvent.CLICK, emailClick);

 

function emailClick(evt:Event){

if (yes1Count == true && yes2Count == true){

note = "These results have come back from a completed Simply Buy Questionnaire:" + "\n\n" + "The participant heard of us from " + formMov.textBox1.text + "\n" + "The participant found what they were looking for and was satisfied with their user experience" + "\n" + "The participant commented, regarding if there were any aspects they would wish to change: " + formMov.textBox4.text + "\n" + "The participant also added the following comments: " + formMov.textBox5.text + "\n\n" + "These results were submitted on " + now

trace(note);

} else if (no1Count == true && no2Count == true){

note = "These results have come back from a completed Simply Buy Questionnaire:" + "\n\n" + "The participant heard of us from " + formMov.textBox1.text + "\n" + "The participant did not find what they were looking for and was not satisfied with their user experience" + "\n" + "The participant commented, regarding if there were any aspects they would wish to change: " + formMov.textBox4.text + "\n" + "The participant also added the following comments: " + formMov.textBox5.text + "\n\n" + "These results were submitted on " + now

trace(note);

} else if (no1Count == true && yes2Count == true){

note = "These results have come back from a completed Simply Buy Questionnaire:" + "\n\n" + "The participant heard of us from " + formMov.textBox1.text + "\n" + "The participant did not find what they were looking for but was satisfied with their user experience" + "\n" + "The participant commented, regarding if there were any aspects they would wish to change: " + formMov.textBox4.text + "\n" + "The participant also added the following comments: " + formMov.textBox5.text + "\n\n" + "These results were submitted on " + now

trace(note);

} else if (yes1Count == true && no2Count == true){

note = "These results have come back from a completed Simply Buy Questionnaire:" + "\n\n" + "The participant heard of us from " + formMov.textBox1.text + "\n" + "The participant found what they were looking for but was not satisfied with their user experience" + "\n" + "The participant commented, regarding if there were any aspects they would wish to change: " + formMov.textBox4.text + "\n" + "The participant also added the following comments: " + formMov.textBox5.text + "\n\n" + "These results were submitted on " + now

trace(note);

}

 

variables.sEmail = "myth.of.echelon@live.com";

variables.sMessage = note;

variables.sSubject = "Questionnaire Results";

 

mailAddress.data = variables;

mailAddress.method = URLRequestMethod.POST;

sendToURL(mailAddress);

}"

 

 

I am not receiving emails when the submit button is clicked. As I am receiving no debug errors when the .swf is compiled and I am receiving feedback from the trace(); functions inside the IF statements, I am inclined to think that the .php is no longer hosted or is incorrectly constructed, for this particular usage. (UPDATE: Upon entering just "www.actionscript.tv" I noticed the website does not exist anymore/never did.)

 

So, to sum up, I need assistance/advice on how to host and use this .php file (as the AS3 is tailored to it) for free to send user results to my email address.

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

I'm sorry for answering a old topic, but anyway, the solution is quite simple.

 

Change

var mailAddress:URLRequest = new URLRequest("http://www.actionscript.tv/email.php");

 

to

var mailAddress:URLRequest = new URLRequest("email.php");

 

Create a new file in your webserver named : email.php

 

add the following content in it.

 

<?php

$sendTo = $_POST["sEmail"];

$subject = $_POST["sSubject"];

$headers = "From: " . $_POST["sName"] . "<" . $_POST["sEmail"] .">\r\n";

$headers .= "Reply-To: " . $_POST["sEmail"] . "\r\n";


$headers .= "Return-path: " . $_POST["sEmail"];



$message = $_POST["sMessage"];


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

?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...