Flash Email Form w/ Cold Fusiom

  • brettbash
  • Novice
  • Novice
  • User avatar
  • Posts: 16

Post 3+ Months Ago

Hey,
Im just seeing if anyone can help me. I am attempting to create a flash and coldfusion email form. Here is the action script for the submit button

Code: [ Select ]
on (release) {
    
myLoadVars = new LoadVars();
      myLoadVars.subject = subject.text;
      myLoadVars.email = email.text;
      myLoadVars.username = username.text;
      myLoadVars.message = message.text;
      myLoadVars.sendAndLoad("contactform.cfm", myLoadVars, "POST");    
 
this.onEnterFrame = function() {
        if (this.send_data.loaded) {



   gotoAndStop(2);
  }
}
}
  1. on (release) {
  2.     
  3. myLoadVars = new LoadVars();
  4.       myLoadVars.subject = subject.text;
  5.       myLoadVars.email = email.text;
  6.       myLoadVars.username = username.text;
  7.       myLoadVars.message = message.text;
  8.       myLoadVars.sendAndLoad("contactform.cfm", myLoadVars, "POST");    
  9.  
  10. this.onEnterFrame = function() {
  11.         if (this.send_data.loaded) {
  12.    gotoAndStop(2);
  13.   }
  14. }
  15. }



Now the location of the submit button and the text boxes are on the same layer, frame and on the main timeline. Its frame one. frame two is were it says "thank you, your mail has been sent." i dont know if there is any other special action scrpit i need to do. I added the vars to each input text box, such as the var for the message box i put message. i dont know if i need to put "myLoadVars" anywhere else. Well, here is the cold fusion script

Code: [ Select ]


< cfmail

to ="my email"
from = "#form.email#"
subject = "#form.subject#"
server = "my server"
username = "my username"
password = "my password">


name : #form.username#
email : #form.email#
message : #form.message#

< /  cfmail  >
  1. < cfmail
  2. to ="my email"
  3. from = "#form.email#"
  4. subject = "#form.subject#"
  5. server = "my server"
  6. username = "my username"
  7. password = "my password">
  8. name : #form.username#
  9. email : #form.email#
  10. message : #form.message#
  11. < /  cfmail  >


now i didnt put my personal stuff, i just put like "my email" instead to just show u what goes there. Any help would be greatly appreciated. Thanks

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

Post 3+ Months Ago

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

Well I don't know anything about CF but I can tell you how to do the same thing with PHP or ASP (the actionscript is the same). There are a few things I see that could probably work the way you have them but might be easier another way.

First instead of placing your code on a button make a new keyframe and give the button an instance name. In the keyframe you need...

Code: [ Select ]
var result_lv:LoadVars = new LoadVars();
var send_lv:LoadVars = new LoadVars();

buttonInstanceName.onRelease = function(){

send_lv.subject = this._parent.subject.text;
send_lv.email = this._parent.email.text;
send_lv.username = this._parent.username.text;
send_lv.message = this._parent.message.text;
send_lv.sendAndLoad("contactform.cfm", result_lv, "POST");
}
  1. var result_lv:LoadVars = new LoadVars();
  2. var send_lv:LoadVars = new LoadVars();
  3. buttonInstanceName.onRelease = function(){
  4. send_lv.subject = this._parent.subject.text;
  5. send_lv.email = this._parent.email.text;
  6. send_lv.username = this._parent.username.text;
  7. send_lv.message = this._parent.message.text;
  8. send_lv.sendAndLoad("contactform.cfm", result_lv, "POST");
  9. }


Note that I added "this._parent." to the path for your text fields because your calling them in relation to the button object and not to the timeline. Also because your using "send" AND "load" you need to build a second object to receive the reply from the server (result_lv).

Now the above should successfully send the information to your script, but since your using send and load you find out when the script is finished with a callback. To do that add this code below the button stuff

Code: [ Select ]
result_lv.onLoad = function(success:Boolean) {
  if (success) {
    // if the server returns something
      gotoAndStop(2);
  } else {
    // the server never sent anything back
      trace("server or connection error");
  }
  };
stop();
  1. result_lv.onLoad = function(success:Boolean) {
  2.   if (success) {
  3.     // if the server returns something
  4.       gotoAndStop(2);
  5.   } else {
  6.     // the server never sent anything back
  7.       trace("server or connection error");
  8.   }
  9.   };
  10. stop();


also since you have a gotoAndStop make sure you place a stop(); at the bottom of that script.

Make sure your CF script returns a value all you have to do in PHP is type something outside of the script close tag
Something like this...
Code: [ Select ]
<? PHP script goes here etc ?> Anything here


basically "Anything here" gets sent back to flash to say the script is done. I don't know if your CF script is correct someone else will have to tell you that but the above actionscript should correctly send and receive from that script
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

Nothing wrong with the cf part. Were you able to get this working brettbash?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

@graphixboy:
did you notice that if you use a button and place the action on it : on(release) { trace(this); } it will not display the button instance, but it's parent?
While if you use a movieclip with the same action on it, trace(this) will actually display the button instance.
But if you place the action in a keyframe, like you did: btn1.onRelease = function() { trace(this); } then it displays the instance of the button as well.

Anyway, that's a good sendAndLoad example you gave him.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

@IceCold

huh I guess i never tried that. Usually don't do the on(release) way.

I suppose that occurs because technically the code is "on" the button and therefor "in" the parent instead of a child of the button object. Although why it works one way with a button and the other with a mc is baffling. I remember some strange implementation of the button.prototype. Its been a while since I actually used something other than a movieclip for a button though.

strange...
  • brettbash
  • Novice
  • Novice
  • User avatar
  • Posts: 16

Post 3+ Months Ago

sorry, that looks like it should work, but i havent had a chance to play with it yet, been pretty busy with lots of other things. ill let you know if i get it working or not
  • bigdog
  • Born
  • Born
  • bigdog
  • Posts: 4

Post 3+ Months Ago

Hi all

I'm very new to Flash 8 and need something really simple. I want to create one input text field where users can type their message and then submit it to my email, using PHP.

So far I've tried everything and nothing is working.

My actionscript is:

on(release){

messager.loadVariables("email.php","POST");

}

where messager is the movieclip instance as well as the name of the input text field variable.

My PHP script is:

<?php

$to = $_POST["bigdog@hotmail.com"];

$message = $_POST["message"];

mail($to, $message);

?>

When I upload to the web and click the submit button, nothing happens. I'm sure this is a fairly simple action but I just can't get it to work.

Please help me with this.

Many thanks in advance.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

hmmm, you know .... to get an answer you don't need to post same thing 1313221312 times to get our attention.
  • bigdog
  • Born
  • Born
  • bigdog
  • Posts: 4

Post 3+ Months Ago

Hi IceCold

Sorry for the multiple replies. :) Told you I was new to this, and most stuff on forums. Yep have been living in a cave far far away.

I actually did try the methods outlined in the debate forum link you provided. I could not get it to work. I contacted my ISP and confirmed they support PHP. Not too sure yet. I'm still looking though and will run a few more searches.

Thanks 1313221312 times for your recommendations. ;) And apologies again for the multiple posts.
  • brettbash
  • Novice
  • Novice
  • User avatar
  • Posts: 16

Post 3+ Months Ago

Alright, I made the changes, and After I click send it says my email has been sent but the firefox progress bar says transfering data still and it doesnt ever stop. also it never send the email, so the fla can be downloaded here. I wanna see if theres anything wrong with it


http://www.megaupload.com/?d=02MLACPA
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

From the way you describe it. I'm thinking the problem is in the CF and not in the Flash. Mostly since the way I described it above, when the script ran it would send something back to flash. However, what it sends back isn't a real complete it just says that the script ran.

Is it possible that the variable names are different in flash and in the CF? I assume they're probably case sensitive but I don't know for sure.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

or the server doesn't have smtp support.
  • brettbash
  • Novice
  • Novice
  • User avatar
  • Posts: 16

Post 3+ Months Ago

everything in the coldfusion is spelled correctly and matches the swf.

the server supports smtp but it requries a login and password
  • zhaojany
  • Student
  • Student
  • User avatar
  • Posts: 79

Post 3+ Months Ago

the fla has gone

Post Information

  • Total Posts in this topic: 14 posts
  • Users browsing this forum: No registered users and 9 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.