View Full Version : Flash & PHP Script
Animosity
12-22-2008, 04:49 PM
From my last question, posted in another board. I finally got my actionscript configured.
on (release) {
//Goto Webpage Behavior
body = "Insale Quote Form";
email = "********@hotmail.com";
querystring = "http://examplepage.net/example.php" +
"&body=Name: " +Name+
"%0AEmail: " +Email+
"%0ACompany: " +Company+
"%0AAddress: " +Address+
"%0ACity, State, Zip: " +Citystatezip+
"%0APhone: " +Phone+
"%0AFax: " +Fax+
"%0A" +
"%0APart Number #1: " +Part1 +
"%0APart Quantity #1: " +Quantity1 +
"%0A" +
"%0APart Number #2: " +Part2 +
"%0APart Quantity #2: " +Quantity2 +
"%0A" +
"%0APart Number #3: " +Part3 +
"%0APart Quantity #3: " +Quantity3 +
"%0A" +
"%0APart Number #4: " +Part4 +
"%0APart Quantity #4: " +Quantity4 +
"%0A" +
"%0APart Number #5: " +Part5 +
"%0APart Quantity #5: " +Quantity5 ++
getURL(querystring,"_self");
//End Behavior
}
How can I modify that for my flash?
zompo
12-22-2008, 05:23 PM
In php when you send the data from flash in the url you have to use $_GET[]
so, for the $sendTo, change it to $sendTo = $_GET['Email'] etc. Though the only thing you seem to send in the url is the body
change the querystring to
querystring = "http://blankpage.com/example.php" +
"?email=" + email +
"&subject=this is my subject"+
"&body=Name: " +Name+
etc
then you will be able to use $_GET['email'], $_GET['subject'], $_GET['body'] in the phpscript.
I dont get it why you do it this way though, and dont use LoadVars,
in flash:
var sendResults:LoadVars = new LoadVars();
sendResults.onLoad = function(success:Boolean) {
if (success)
{
// do something if all is ok
}
else
{
// do something when error
}
}
var sendData:LoadVars = new LoadVars();
sendData.email = "email";
sendData.somethingelse = "somethingelse";
sendData.sendAndLoad("myphp.php",sendResults, "POST");
and then in php
<?php
$email = $_POST['email'];
$somethingelse = $_POST['somethingelse'];
echo '&ready=ok';
?>
Animosity
12-22-2008, 06:16 PM
And I'm still stuck, can you explain it any clearer?
Animosity
12-23-2008, 04:55 PM
Well, thanks to Zompo for giving me more tutorials or so. THe PHP & FLash form works and sends. I did a small test run to see if it will send though now. But! I need the action script to send in multiple things now.
The name instances are:
subject_box
name_box
email_box
company_box
csz_box (City, State, Zip)
phone_box
fax_box
Part_box
The Action Script
stop();
System.useCodepage = true;
send_btn.onRelease = function() {
my_vars = new LoadVars();
my_vars.sender = email_box.text;
my_vars.subject = subject_box.text;
my_vars.message = part1_box.text;
if (my_vars.sender != "" and my_vars.subject != "" and my_vars.message != "") {
my_vars.sendAndLoad("http://*******.com/flash/mailer.php", my_vars, "POST");
gotoAndStop(2);
} else {
error_clip.gotoAndPlay(2);
}
my_vars.onLoad = function() {
gotoAndStop(3);
};
};
email_box.onSetFocus = subject_box.onSetFocus=message_box.onSetFocus=func tion () {
if (error_clip._currentframe != 1) {
error_clip.gotoAndPlay(6);
}
};
The PHP Script: From MacromediaHelp
<?php
$subject = $_REQUEST["subject"];
$message = $_REQUEST["message"];
$sender = $_REQUEST["sender"];
$full_message = $_SERVER['REMOTE_ADDR'] . "\n\n" . $message;
$message= $full_message;
$message = stripslashes($message);
$subject = stripslashes($subject);
$sender = stripslashes($sender);
$subject = $subject;
if(isset($message) and isset($subject) and isset($sender)){
mail("*****@hotmail.com", $subject, $message, "From: $sender");
}
?>
Now, what would I need to to have the message being of the Name, Company, Address, Phone,Number, Fax, and Part Number and Quantity for both AS and PHP[/QUOTE]
CyanBlue
12-23-2008, 05:09 PM
Please keep your question to one thread... It's best to keep your question in chain so that people can see the progress... That benefits those who tries to help you, and those who is searching for the solution... Thanks...
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.