Jump to content

[SOLVED] noob needs help with flash form


designledge

Recommended Posts

ok. i've come to a very sobering conclusion after 12 hours in front of my computer dealing with flash- i suck at php.

 

i'm trying to create a very simple contact form in flash that when submitted sends an email to the designated email address. so far, all of the validation aspects work, but after everything appears to work after submitting the form, i still dont receive anything in my inbox.

 

here's the flash site: www.sold-onstaging.com

 

i'm using:

flash cs3 as 2.0

dreamweaver cs3 for the php code

linux server with php 4.0

here's my flash code:

//create the LoadVars objects which will be used later
//one to send data...
dataSender = new LoadVars();
//and one to catch what comes back
dataReceiver = new LoadVars();

/*DEFINE SUBMIT BUTTON BEHAVIOR*/
submit.onRelease = function() {
//final check to make sure fields are completed
if (name_txt.text != '' &&
   email_txt.text != '' &&
   comments_txt.text != '') {
   alert_txt.text='';//clear any previous error messages or warnings
   //advance playhead to frame 2 - the "processing" message
   _root.play();
   
   //assign properties to LoadVars object created previously
   dataSender.name = name_txt.text;
   dataSender.company = company_txt.text;
   dataSender.phone = phone_txt.text;
   dataSender.email = email_txt.text;
   dataSender.comments = comments_txt.text;
   
   //callback function - how to handle what comes back
dataReceiver.onLoad = function() {
   if (this.response == "invalid") {
      _root.gotoAndStop(398);
      alert_txt.text = "Please check email address"
   } else if (this.response == "error") {
      _root.gotoAndStop(400);
   } else if (this.response == "passed") {
         _root.gotoAndStop(401);
   }
}
//now send data to script
   dataSender.sendAndLoad("sosform.php", dataReceiver, "POST");

   
   } else {
   //warning if user tries to submit before completing form
   alert_txt.text = "Please fill in required fields";
   }
}

 

and here's the php code: (i have replaced "[email protected]" with my email address)

 

<?php

//create short variable names
$name=$_POST['name'];
$company=$_POST['company'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$comments=$_POST['comments'];

$subject = 'Website Hit';

/*#########
modify the next line with your own email address
###########*/

$toaddress='[email protected]';


if (preg_match ("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email)) {
    mail($toaddress,$subject,$comments,"From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\n");
     //clear the variables
     $name='';
     $company='';
     $phone='';
     $email='';
 $comments='';
     echo "response=passed";
} else {
	echo "response=invalid";
	exit;
}

?>

 

 

does anyone have any idea what im doing wrong??

 

 

Link to comment
https://forums.phpfreaks.com/topic/119007-solved-noob-needs-help-with-flash-form/
Share on other sites

Try echoing all the vars in the php section to ensure they all say what you intend for them to. Assuming they do, attempt to see whether the mail() function is returning true or false. If it is returning true, you might consider that your email is being blocked by your email provider. If possible try to whitelist your domain, or try a different email address.

 

Once you've tried all of that or if you need help with any of it, don't be afraid to ask :)

thanks generic- i checked my email and sure enough it wasnt working... horrible timing i guess. so i get all excited, change my addy in php, and find out that now the form wont get passed the "processing" movie. i cant remember for the life of my how i got it to the "thank you" page last night...

sweet i figured it out. there was a stupid "{" in the wrong place in flash... i'll post the code in case anyone else out there wants to use it- and thanks again generic

 

flash:

 

//create the LoadVars objects which will be used later
//one to send data...
dataSender = new LoadVars();
//and one to catch what comes back
dataReceiver = new LoadVars();

/*DEFINE SUBMIT BUTTON BEHAVIOR*/
submit.onRelease = function() {

//final check to make sure fields are completed
if (name_txt.text != '' &&
   email_txt.text != '' &&
      comments_txt.text != '') {
   alert_txt.text='';//clear any previous error messages or warnings
   //advance playhead to next frame - the "processing" message
   _root.play();
   
   	//assign properties to LoadVars object created previously
   dataSender.name = name_txt.text;
   dataSender.company = company_txt.text;
   dataSender.phone = phone_txt.text;
   dataSender.email = email_txt.text;
   dataSender.comments = comments_txt.text;
   
   //callback function - how to handle what comes back
dataReceiver.onLoad = function() {
   if (this.response == "invalid") {
      _root.gotoAndStop(398);
      alert_txt.text = "Please check email address"
   } else {if (this.response == "passed") 
      _root.gotoAndStop(401);
   }
}

//now send data to script
   dataSender.sendAndLoad("sosform.php", dataReceiver, "POST");
   
   } else {
   //warning if user tries to submit before completing form
   alert_txt.text = "Please fill in required fields";
   }
}

 

 

php:

 

<?php

//create short variable names
$name=$_POST['name'];
$company=$_POST['company'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$comments=$_POST['comments'];

$subject = 'Website Hit';

/*#########
modify the next line with your own email address
###########*/

$toaddress='[email protected]';


if (preg_match ("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email)) {
    mail($toaddress,$subject,$comments,"From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\n");
     //clear the variables
     $name='';
     $company='';
     $phone='';
     $email='';
 $comments='';
     echo "response=passed";
} else {
	echo "response=invalid";
	exit;
}

?>

Archived

This topic is now archived and is closed to further replies.

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