Jump to content

Php w/ flash component form


E_Rock

Recommended Posts

So basically I'm making a quote request form in flash for my dad and everything is working perfectly... EXCEPT that when you click submit it's supposed to read back "Thanks $senderName, you quote request has been submitted" but strangely it reads back my entire Php code... Any help would be awesome ! 

 

<?php
//Creat local variables from Flash ActionScript posted variables
$senderName =$_POST['userName'];
$senderCompany =$_POST['userCompany'];
$senderEMail =$_POST['userEMail'];
$senderPhone =$_POST['userPhone']; 
$senderComment =$_POST['userComment'];
$senderStandardStock =$_POST['userStandardStock'];
$senderStandardQuantity =$_POST['userStandardQuantity'];
$senderMonarchStock =$_POST['userMonarchStock'];
$senderMonarchQuantity =$_POST['userMonarchQuantity'];
$sender1stColor =$_POST['user1stColor'];
$sender2ndColor =$_POST['user2ndColor'];
$senderEmboss =$_POST['userEmboss'];
$senderFoilStamp =$_POST['userFoilStamp'];
$senderStockSupplied =$_POST['userStockSupplied'];
$senderFoilE =$_POST['userFoilE'];
$senderMGT =$_POST['userMGT'];

//Strip slashes on the Local typed-in variables for security and run any PHP based error check here
$senderName =stripslashes($senderName);
$senderCompany =stripslashes($senderCompany);
$senderEMail =stripslashes($senderEMail);
$senderPhone =stripslashes($senderPhone);

$to ="websales@winsted-thermo.com";
$from ="$senderEMail";
$subject ="Quote Request from $senderName at $senderCompany";
$message="Quote Request from $senderCompany
Name: $senderName
E-Mail: $senderEMail
Company: $senderCompany
Phone #: $senderPhone
Stock: Standard:$senderStandardStock
        Monarch:$senderMonarchStock
Quantity: Standard:$senderStandardQuantity
           Monarch:$senderMonarchQuantity
Color 1st: $sender1stColor
      2nd: $sender2ndColor
Embossing?: $senderEmboss
Foil Stamping?: $senderFoilStamp
Foil Embossing?: $senderFoilE
Metallic Gold Thermography?: $senderMGT
Stock Supplied?: $senderStockSupplied
Additional Comments: $senderComment";

//Build $headers Variable
$headers = "From: $from\r\n";
$headers = "Content-type: text\r\n";
$to = "$to";
// Send the EMail
mail($to, $subject, $message, $headers);

//Assemble the message that goes back to flash
//The flash ActionScpri is looking for a return of "return_msg"
$my_msg= "Thanks $senderName, your quote request has been sent.";
//Print the data back to flash who is patiently waiting for it in the onCompleteHandler
print "return_msg=$my_msg";

//Exit script
exit();
?>

 

V--Part of my AS3 coding--V

// upload_btn function

var uploadCLICKURL:URLRequest = new URLRequest("uploadFile.html");

upload_btn.addEventListener(MouseEvent.CLICK, uploadCLICK);

function uploadCLICK(event:MouseEvent):void {

navigateToURL(uploadCLICKURL,"_blank");

}

//Build the varSend varialble

var variables:URLVariables=new URLVariables;

var varSend:URLRequest=new URLRequest("form_parse.php");

varSend.method=URLRequestMethod.POST;

varSend.data=variables;

 

//Build the varLoader variable

var varLoader:URLLoader=new URLLoader;

varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

varLoader.addEventListener(Event.COMPLETE, completeHandler);

 

 

//handler for the PHP script completion and return of status

function completeHandler(event:Event):void {

process_mc.visible = false;

Name.text="";

Company.text="";

E_Mail.text="";

Phone.text="";

Comment.text="";

Emboss.selected=false;

FS.selected=false;

S_Supplied.selected=false;

FoilE.selected=false;

MGT.selected=false;

//Load the response php here

status_txt.text=String(event.target.data)<--- This is where it's supposed to pull the response message from my php file

}

 

// Add event listner for submit button click

submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);

 

// function ValidateAndSend

function ValidateAndSend(event:MouseEvent):void {

 

// Validate Email Function

function validateEmailAddress(emailString:String):Boolean {

 

var myRegEx:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;

var myResult:Object = myRegEx.exec(emailString);

if (myResult == null) {

return false;

}

return true;

}

 

if (!Name.length) {

status_txt.text="*Please fill in all the text feilds";

} else if (!Company.length) {

status_txt.text="*Please fill in all the text feilds";

} else if (!E_Mail.length) {

status_txt.text="*Please fill in all the text feilds";

} else if (validateEmailAddress(E_Mail.text) == false) {

status_txt.text = "Please enter a VALID email address.";

} else if (!Phone.length) {

status_txt.text="*Please fill in all the text feilds";

} else {

 

//All is good, send the data now to PHP

process_mc.visible = true;

//ready the variables in our form for sending

variables.userName=Name.text;

variables.userCompany=Company.text;

variables.userEMail=E_Mail.text;

variables.userPhone=Phone.text;

variables.userComment=Comment.text;

variables.userStandardStock=S_Stock.value;

variables.userStandardQuantity=S_Quantity.value;

variables.userMonarchStock=M_Stock.value;

variables.userMonarchQuantity=M_Quantity.value;

variables.user1stColor=Ink_Color1.value;

variables.user2ndColor=Ink_Color2.value;

variables.userEmboss=Emboss.selected;

variables.userFoilStamp=FS.selected;

variables.userStockSupplied=S_Supplied.selected;

variables.userFoilE=FoilE.selected;

variables.userMGT=MGT.selected;

 

//Send the datd to PHP now

varLoader.load(varSend);

}// close else condition for error handling

 

}//close ValidateAndSend

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.