Trouble linking AS3 and PHP to create email form

I am using one of the Adobe cookbooks to create an email form for my flash website. I am SO close to getting this right and need some help! I used the AS3 code below as well as the PHP code below in order to create the email form. Everything seems to be working fine, that is until I try to send an email using the form. When I input all of the text into the form, I get the actionscript default warning I wrote that states "Oh no! Something is wrong! Try again..." Hence the email will not send. What could be wrong with the script? Or does it matter where I file the PHP file, my swf file, html file, and my fla file? I tried several combinations of filing everything together, seperate, and everything in between. Help! And thanks for anyone who can help!
ACTIONSCRIPT CODE USED:
stop();
Buttons      
sendbtn.buttonMode = true;
sendbtn.addEventListener(MouseEvent.CLICK, submit);
resetbtn.buttonMode = true;
resetbtn.addEventListener(MouseEvent.CLICK, reset);
Variables needed       
var timer:Timer; var varLoad:URLLoader = new URLLoader;
var urlRequest:URLRequest = new URLRequest( "mail.php" );
urlRequest.method = URLRequestMethod.POST;
Functions
function init():void{
//Set all fields to empty
yourName.text = "";
fromEmail.text = "";
yourSubject.text = "";
YourMsg.text = "";
function submit(e:MouseEvent):void{
//Check to see if any of the fields are empty
if( yourName.text == "" || fromEmail.text == "" ||
yourSubject.text == "" ||YourMsg.text == "" )
{ valid.text = "All fields need to be filled.";
//Check if you're using a valid email address
else if( !checkEmail(fromEmail.text) )
{ valid.text = "Enter a valid email address"; }
else { valid.text = "Sending over the internet...";
var emailData:String = "name="
+ yourName.text + "&from="
+ fromEmail.text + "&subject="
+ yourSubject.text + "&msg=" + YourMsg.text;
var urlVars:URLVariables = new URLVariables(emailData);
urlVars.dataFormat = URLLoaderDataFormat.TEXT;
urlRequest.data = urlVars; varLoad.load( urlRequest );
varLoad.addEventListener(Event.COMPLETE, thankYou );
function reset(e:MouseEvent):void{
init(); //call the initial clear function
function checkEmail(s:String):Boolean {
//This tests for correct email address
var p:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/; var
r:Object = p.exec(s);
if( r == null ) {
return false;
return true;
function thankYou(e:Event):void {
var loader:URLLoader =
URLLoader(e.target);
var sent = new
URLVariables(loader.data).sentStatus; if( sent == "yes" )
valid.text = "Thanks for your email!";
timer = new Timer(500);
timer.addEventListener(TimerEvent.TIMER, msgSent);
timer.start();
else {
valid.text = "Oh no! Something is wrong! Try again..."; }
function msgSent(te:TimerEvent):void {
if( timer.currentCount >= 10 ) { init();
timer.removeEventListener(TimerEvent.TIMER, msgSent);
PHP CODE USED
<?php $yourName = $_POST['name'];
$fromEmail = $_POST['from']; 
$yourSubject = $yourSubject = $_POST['subject'];
$YourMsg = $_POST['msg'];
if( $yourName == true ) { $sender = $fromEmail; $yourEmail ="[email protected]";  (I have changed this to my email address, although not given in example)
$ipAddress = $_SERVER['REMOTE_ADDR']; 
$emailMsg = "$ipAddress \n$yourName  \n$sender
\n\n$YourMsg 
\n\n\n--Memo for myself--";$return = "From: $sender\r\n" .
"Reply-To:$sender \r\n" ."X-Mailer: PHP/" . phpversion();
if( mail( $yourEmail, "$yourSubject", $emailMsg, $return
echo "sentStatus=yes"; }
else { echo "sentStatus=no"; } }
{ $sender = $fromEmail; $yourEmail ="$fromEmail"; 
$emailMsg = "\n\n\n--Memo for the sender. i.e. this is a copy of message you sent me.--
\n\n$yourName  \n$sender
\n$YourMsg \n";$return = "From: $sender\r\n" .
"Reply-To:$sender \r\n" ."X-Mailer: PHP/" . phpversion();
if( mail( $yourEmail, "$yourSubject", $emailMsg, $return
echo "sentStatus=yes"; }
else { echo "sentStatus=no"; } }
?>

It may be indeed a problem of your server rsp. how it handles security issues and relative path-linking.
You wrote: "Or does it matter where I file the PHP file, my swf file, html file, and my fla file..." I suppose you mean where to put all the files.
1.Its a good beginners choice to put all the files you need (swf, html, php you don`t need the fla file on ) in the same directory of your server.
2.If you publish to html from flash there will be three tags in the html (use a texteditor to look at the html-code) that read like this:
<param name="allowScriptAccess" value="sameDomain" />
change them for testing purposes to
<param name="allowScriptAccess" value="always" />
3.On some servers to prevent malicious code php scripts are restricted to certain directorys, look up the phpinfo on your server
4.Even if swf, html and php are in one and the same directory use a "hard" path in your fla file for testing purposes, for example instead of calling "file.php" in your actionscript, call ("http://www.mydomain.com/directory/file.php"), when testing from flash you may get a better response where the problem lies

Similar Messages

  • I have date type list field in sharepoint list and i have created one form in sharepoint webpage.

    Hi All,
    i have date type list field in sharepoint list and i have created one form in sharepoint webpage.
    Now i want to save that field from shareepoint webpage, its declared "t1.text" but its showing error.
    How can i save this field?

    Hi AnilKarthink, 
    I wrote a Technet Wiki article on saving data to the various SharePoint fields. You can view it here: http://social.technet.microsoft.com/wiki/contents/articles/21801.sharepoint-a-complete-guide-to-getting-and-setting-fields-using-c.aspx
    Regards, Matthew
    MCPD | MCITP
    My Blog
    View
    Matthew Yarlett's profile
    See my webpart on the TechNet Gallery that allows administrative users to upload, crop and format user profile photos. Check it out here:
    Upload and Crop User Profile Photos

  • How to create HTML fragment and PHP file for CONTACT FORM?

    Hello!
    I need to add a contact form to my website.
    I don't want to use wufoo or similar.
    Can someone write a code to have a form:
    NOME:
    MAIL:
    MESSAGGIO:
    and file .php ?
    Regards.
    Thanks a lot.

    Where are you publishing your site to? If MMe, then MobileMe does not support php and you don't need php to create a contact form - just good old html.
    If you are uploading to a server/host such as GoDaddy, then you can use the FormMail option too, but you still need to write your own html code - others will not do it for you.
    I would suggest that you visit this site - http://www.w3schools.com. This site tells you about how to write html code for most things, including contact and feedback forms. Look at this and then write your own code from this.
    If you can't manage to do it, then I would suggest that you need to use something like http://www.wufoo.com or GoogleDocs - Google Docs is a good alternative.
    Also, do a search of this forum for contact or contact and feedback forms where you will find lots of questions on this and where you will then find code examples that have been linked to.
    If you try it yourself, you will learn more quickly rather than asking others to do it for you.

  • Using Javascript and ScriptUI to create a form that brings in a symbol from library

    Hello everyone,
    I've been trying to pull together the right info to use javascript to create a form to bring in particularsymbols from the symbol library based on the variables taken from the form. I've taken bits and pieces from various sample scripts and tried to make this work, but my problem appears when I try to use conditionals.
    This is a limited version of what I want to do, but it is enough to get the point across.
    1. I want to select a script that has various dropdown boxes. I would like the first dropdown to give me 3 options: 10, 13, 18
    2. I would also like another drop down box that gives me three more options: single needle, double needle, and knife edge.
    3. I would then like it to have an "ok" button and "Cancel" button.
    4. From here when I click the ok button, a symbol is brought in from the library depending on what parameters were given to the form.
    ex. If I selected 10 in the first drop down and double needle in the second, I would like "SYMBOL A" to be pulled from the library and centered on the artboard.
    ex. If I selected 13 in the first drop down and double needle in the second, I would like "SYMBOL B" to be pulled from the library and centered on the artboard.
    I've gotten the UI to pop up and it works as planned as well as bringing in a symbol, my problem comes when I try to incorporate conditionals and functions.
    Here is my script. Please let me know what I'm doing wrong.
    var myDoc = app.activeDocument;
    var Pallette = new Window ("dialog", "Create a Shell");
    Pallette.add ("statictext", undefined, "Fill Opening in Inches:");
    Pallette.orientation = "row";
    var myDropdown =  Pallette.add ("dropdownlist", undefined, ["10", "13", "18"]);
    myDropdown.selection = 1;
    var myButtonGroup =  Pallette.add ("group");
    myButtonGroup.orientation = "column";
    var btnCreate = myButtonGroup.add ("button", undefined, "OK");
    MyFillSelection = myDropdown.selection
    btnCreate.onClick = function () {
        if ( MyFillSelection = "13") {
                   symbolRef = myDoc.symbols["SYMBOL A"];
            symbolItemRef1 = myDoc.symbolItems.add(symbolRef);
           redraw();
    var btnCancel = myButtonGroup.add ("button", undefined, "Cancel");
      Pallette.show ();
    If anyone has any input, it would be much appreciated.
    thanks,

    MyFillSelection = myDropdown.selection is outside the function, so it will always read "13", nothing is making the value change.
    move that line into your function and add the text property to it...MyFillSelection = myDropdown.selection.text;
    then do your if comparisons, that will do it.

  • I am having trouble deleting files and folders after creating in the same .VI

    I have a larger .VI that runs an automated balancing routine for a large rotating mass.  The test needs to create some folders and files so that as the rest is run multiple times, there is a way to track how units did under test and when they were tested.
    The attached .VI is only the portion of the code that creates the files and folders, waits for user input, and then deletes them if the test is cancelled before data is collected.  There are other elements, but they are irrelevant given that I can't even get the stripped down code to work.  I have checked the permissions on the deepest file (within both folders) and I am unable to get 777(oct) permissions on this file which could be the only problem I have.  Does anyone have any suggestions?
    Attachments:
    test1.vi ‏47 KB

    Here are a couple of things:
    Frame 0: the pane properties are saved with the file, so once they are set you never need to set them again. Delete the property node and associated constants.
    Frame 1:
    Shouldn't "Serial#" be a control (and an integer)? You do a complex song and dance to add leading zeroes. Simply format your serial number with format "%04d"
    Shouldn't "Operator" be a control?
    Frame 2: That loop needs a small wait statement. Since STOP is always true when the loop ends, the later case structure seems unneeded.
    Frame 3:
    the STOP function seems unneeded. the VI will stop anyway since there is no code left.
    never use default tunnels for references.
    All your error outputs are "disconnected" and write to the same indicator. Mist likely you'll loose intermediary errors.
    Overall, you should use a state machine architecture instead of sequences. It will be much more flexible and will take even less diagram space. The indicators can be outside the state case, so all states can write to them. No locals needed.
    LabVIEW Champion . Do more with less code and in less time .

  • TS3899 i have followed info re not being able to set up an email account plus trouble shooting tips and still cant get email account to work

    I have tried to set up a hotmail email account on phone but it keeps saying cant verify and then says password I'm entering is incorrect.  I know its correct password as I have reset it via PC... any ideas please?

    You might want to try removing they email account and setting it back up again

  • Creating email form for distribution from a recordset

    I am new to the Master Collection of Adobe's products.  I am coming from Macromedia 8 Studio.  In that earlier version I used Dreamweaver to create a recordset (from a table resident on the server) and I looped through a list of email addresses, sending a custom form that personalized the content with fields from the recordset.  CFMAIL was the tag that I used in getting this done.  The file created was cfm.
    Not that I am asking for a "how to" at this time, I am wondering what might be an alternate accomplishing the same thing with the latest applications within the suite. 
    Also, I have always shyed away from including graphics for fear that the recipient would trash the email if he had to click a dialogue asking whether graphics should be displayed.  Other departments within the firm are using Constant Contact to accomplish all of this, and they apparently are successful at sending graphics that display upon the opening of an email with no such prompting.  I would rather not use Constant Contact.
    They keep me busy here, and I must admit that I have not had the time to explore the array of products that I now have at my disposal.  Any direction that you can lend would be appreciated.

    Have a look here http://kb.mailchimp.com/article/how-to-code-html-emails

  • Creating email forms

    Hey, i have dreamweaver 8 and ive been making a site for a
    while now and all along ive been using an online form maker..b ut i
    want to make my own. Ive made the form and set the properties to
    action: mailto:[email protected]
    method: GET
    enctype:text/plain
    I saved it.. and then tested it, but it sends it in outlook!
    How can i make it so it sends it straight from the page with out
    using any other software to send... thanks!

    Sorry i double posted! Please use the post above this one,
    thanks.

  • Highscore list using Flash and PHP

    Hi,
    I want to make a highscorelist using AS3 and PHP(MySQL).
    I cant find a good tutorial on internet how to make something like that but I got this so far:
    import fl.controls.TextInput;
    import fl.controls.TextArea;
    var variables:URLVariables = new URLVariables();
    variables.name = "Wil";
    variables.final = 2000;
    var request:URLRequest = new URLRequest();
    ////insert in the location of the php script ////////////////
    request.url = "http://www.justenter.nl/script.php";
    request.data = variables;
    var loader:URLLoader = new URLLoader();
    loader.load(request); //sends the request
    //when the request is done loading, it goes to the completeWriting function
    loader.addEventListener(Event.COMPLETE, completeWriting);
    function completeWriting(event:Event):void {
        var writingCompleted:TextField = new TextField;
        writingCompleted.autoSize = "center";
        writingCompleted.x =200;
        writingCompleted.y= 200;
        writingCompleted.text = event.target.data;
        addChild(writingCompleted);
    He is sending the score and name to the database but he is doing that when i press ctrl-enter. He is sending the data I have given in:
    variables.name = "Wil";
    variables.final = 2000;
    I want a input textfield and a button. And When I fill in my name in the input textfield he send it to the database when I press the button.
    Is there someone that can help me out?
    Tnx

    import fl.controls.TextInput;
    import fl.controls.TextArea;
    var variables:URLVariables = new URLVariables();
    //variables.name = "Wil";
    //variables.final = 2000;
    var request:URLRequest = new URLRequest();
    ////insert in the location of the php script ////////////////
    request.url = "http://www.justenter.nl/script.php";
    request.data = variables;
    var loader:URLLoader = new URLLoader();
    submitBtn.addEventListener(MouseEvent.CLICK,submitF);  // where submitBtn is your button
    function submitF(e:Event){
    variables.name=nameTF.text; // where nameTF is your input texfield
    variables.final = score;  // where score is the variable you use to tally user score
    loader.load(request); //sends the request
    //when the request is done loading, it goes to the completeWriting function
    loader.addEventListener(Event.COMPLETE, completeWriting);
    function completeWriting(event:Event):void {
        var writingCompleted:TextField = new TextField;
        writingCompleted.autoSize = "center";
        writingCompleted.x =200;
        writingCompleted.y= 200;
        writingCompleted.text = event.target.data;
        addChild(writingCompleted);

  • Create dynamic forms

    Hello,
    Hello I have an application based on JSF. We have a requirement to create forms dynamically, I mean end user should be able to add new controls to the form, without recompiling the application. Do u know some frameworks that do this ? For instance , I edit and xml file , and the application creates the form based on that. ? I was reviewing ORBEON framework, and I like the idea that with editing and xhtml file , I can make changed to the form and form submits XML information , but it seems to me complex or a long learning curve , besides it is a completely diferrent technology than JSF........do u know any similar idea like ORBEON , but implemented in JSF ? or how to integrate Orbeon and JSF ? . I want to keep the business logic in java code, and presentation in XFORMS
    Thanks,
    Deibys Quintero

    I'm in charge of the opensource project named XSLTForms (http://www.agencexml.com/xsltforms/).
    It's a client-side XForms solution based on XSLT to generate XHTML+Javascript.

  • Somebody has created an apple id using my gmail id. So I gave forgot password option and reset the password of the id. But for resetting the security questions, link is going to some other email id which is created by the other guy.How can I resolve this?

    When I tried to create and apple id using my gmail account i found that somebody has already created an apple id using my gmail id. So I gave forgot password option and reset the password of the id. But for resetting the security questions, link is going to some other email id which is created by the other guy. Now the problem is that the other guy also can reset my password and access my account.
    I contacted apple customer care and they are not ready to help me saying that I need to give information about the last device I logged in using this id. How can I give it when I did not create it?:) Also they are saying this account has been verified and that could happen only if someone has hacked my gmail account and verified the id using the link sent by apple.
    Later I did some experiments and found that this is a security flaw from apple. Somebody has created the id and never used it(I tried to loggin to icloud and it was saying this account was not used it any apple device). The account became verified when I reset the password.(This is a bug, account should be verified only when we click on the verification link sent by apple).
    The other mistake apple did is that they allotted my gmail account to someone before it's verified eventhough it cannot be used unless verified. Actually apple should allot the account id only after verifying the email address.
    Apple customer care is not ready to help and I am tired of fighting with them. Can any of you guys suggest any means of getting back my gmail id to use it as apple id?

    I don't think you're going to be able to. I would guess the other person used your address by accident, and when he found he couldn't access the account (because you'd changed the password) he abandoned it. Your GMail address is now locked to that account and even if it was changed you can't use it to create another.
    You already have an Apple ID, which you use to log in here; you can use that to create an iCloud account if that's what you are trying to do. If you want to create a different Apple ID just get another free address such as a Yahoo one.

  • I recently downloaded mountain lion and just had it emailed to me but I'm having trouble downloading it to my computer. I cannot find the button that says "redeem" under quick links.

    I recently downloaded mountain lion and just had it emailed to me but I'm having trouble downloading it to my computer. I cannot find the button that says "redeem" under quick links.

    You must have a minimum of OS X Snow Leopard 10.6.8 installed on your Mac to have the Mac App Store. The Quick Links are on the Featured pane.

  • After creating an apple ID it says it has to verify my email adress and will send an email with a verification link. I never get the email.

    I created an iapple id and it said it had to send me a verification email to verify my email adress. It said ....email sent please click on link. I did this several times and although it says email sent...i never get the email.

    Apple ID security issues -
    Account security issues almost always require you to speak directly to an Apple representative to securely establish your identity as the account holder. You can set it up so that Apple calls you, either immediately or at a time convenient to you.
    1. Go to https://getsupport.apple.com/Issues.do
    2. Choose Other Apple ID Topics and choose the appropriate topic for your issue
    4. Follow the onscreen instructions

  • I am trying to create an itunes account.  There doesn't seem to be a link to click 'I agree' to the terms and conditions on the email sent to me.  Can anyone help?  Thanks.

    I am trying to create an itunes account on an ipad mini IOS 8.1.  There doesn't seem to be a link to click 'I agree' to the terms and conditions on the email sent to me.  Can anyone help?  Thanks.

    Create a NEW account/ID for her using these instructions. Make sure you follow the instructions. Many do not and if you do not you will not get the None option. You must use an email address that you have not used with Apple before. Make sure you specify a birthdate that results in being at least 13 years old
      Creating an iTunes Store, App Store, iBookstore, and Mac App Store account without a credit card
    More details of how:
    http://ipadhelp.com/ipad-help-tips-tricks/how-to-get-free-apps-from-the-app-stor e-without-a-credit-card/

  • [Exclusive] Create AS3 and MXML in your PHP pages - Q and A

    One of the most common PHP scripts is a form.  Before FTML, there has never been a method of truely integrating Flash with PHP.  Flash and PHP have always been seperate sandboxes when developing.  FTML now allows you to write PHP and FTML hand in hand on the same page.  This removes the requirement of additional files or web services for PHP to interact with Flash.
    PHP to Flash: http://reshapemedia.com/ftml/learn/php-to-ftml/
    FTML Getting Started Guide: http://reshapemedia.com/ftml/downloads/getting-started-guide/
    PHP Requirements
    None - simply code as you would normally and include the MXML components rather than HTML.
    Form Requirements
    All Form children must have the [name] property set
    Any UI For child with the [id] property set will be processed with the Form
    Forms should have [relativeChildSize] set to "true"
    Forms support a [method] of "get", "post", "send", "refresh"
    Inputs with a [type] of "text" or "password" support the [enter] key press
    Example PHP File
    Adobe will not let me post the example code so you can view the demo here: http://reshapemedia.com/examples/ftml-form.php
    - Select [View Source] from your menu to see the code.
    Message was edited by: ReshapeMedia

    It's a little hard to understand your question and its context. Can you please upload this page and give us a link so we can see what you are describing?

Maybe you are looking for