Results 1 to 8 of 8

Thread: Contact form help

  1. #1
    Join Date
    Aug 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Contact form help

    I have a flash contact form that when I click the submit button the form says message sent but the message doesn't go to my email inbox. The as3 code and php are listed below.

    package contact_fla
    {
    import adobe.utils.*;
    import caurina.transitions.*;
    import caurina.transitions.properties.*;
    import flash.accessibility.*;
    import flash.display.*;
    import flash.errors.*;
    import flash.events.*;
    import flash.external.*;
    import flash.filters.*;
    import flash.geom.*;
    import flash.media.*;
    import flash.net.*;
    import flash.printing.*;
    import flash.profiler.*;
    import flash.sampler.*;
    import flash.system.*;
    import flash.text.*;
    import flash.ui.*;
    import flash.utils.*;
    import flash.xml.*;

    public dynamic class MainTimeline extends flash.display.MovieClip
    {
    public function MainTimeline()
    {
    super();
    addFrameScript(0, frame1);
    return;
    }

    public function imageClicked(arg1:flash.events.MouseEvent):void
    {
    flash.net.navigateToURL(new flash.net.URLRequest(xml.settings.@url), "_blank");
    return;
    }

    public function init(arg1:flash.events.Event):void
    {
    this.removeEventListener(flash.events.Event.ADDED_TO_STAGE, init);
    rootBlurMask = flash.display.MovieClip(stage.getChildAt(0)).blurMask;
    stage.align = flash.display.StageAlign.TOP_LEFT;
    stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;
    stage.addEventListener(flash.events.Event.RESIZE, resizeHandler, false, 0, true);
    if (stage.displayState == flash.display.StageDisplayState.FULL_SCREEN)
    {
    stage.displayState = flash.display.StageDisplayState.NORMAL;
    }
    loadCSS();
    if (flash.display.MovieClip(stage.getChildAt(0)).curXML)
    {
    xmlLoader.load(new flash.net.URLRequest(flash.display.MovieClip(stage.getChildAt(0)).curXML));
    }
    else
    {
    xmlLoader.load(new flash.net.URLRequest("xml/contact.xml"));
    }
    return;
    }

    public function sendBtnClicked(arg1:flash.events.MouseEvent):void
    {
    if (form.nameInput.text == "" || form.emailInput.text == "" || form.subjectInput.text == "" || form.messageInput.text == "")
    {
    form.errorTxt.text = xml.settings.@missingFieldsErrorTxt;
    }
    else if (form.emailInput.text.indexOf("@") < 2 || form.emailInput.text.indexOf(".") < 0)
    {
    form.errorTxt.text = xml.settings.@emailAddressErrorTxt;
    }
    else
    {
    form.errorTxt.text = xml.settings.@messageSentTxt;
    var loc1:*;
    form.messageInput.text = loc1 = "";
    form.subjectInput.text = loc1 = loc1;
    form.emailInput.text = loc1 = loc1;
    form.nameInput.text = loc1;
    }
    return;
    }

    public function checkSuccess(arg1:flash.events.Event):void
    {
    var loc1:*=flash.net.URLLoader(arg1.target);
    var loc2:*=new flash.net.URLVariables(loc1.data).status;
    if (loc2 != "success")
    {
    form.errorTxt.text = xml.settings.@messageNotSentTxt;
    }
    else
    {
    form.errorTxt.text = xml.settings.@messageSentTxt;
    var loc3:*;
    form.messageInput.text = loc3 = "";
    form.subjectInput.text = loc3 = loc3;
    form.emailInput.text = loc3 = loc3;
    form.nameInput.text = loc3;
    }
    return;
    }

    public function removeFromStage():void
    {
    xmlLoader = null;
    cssloader = null;
    stage.removeEventListener(flash.events.Event.RESIZE, resizeHandler);
    caurina.transitions.Tweener.addTween(sideTxt, {"x":-500, "time":1, "delay":0.3, "transition":"easeInOutExpo"});
    caurina.transitions.Tweener.addTween(form, {"x":-500, "time":1, "delay":0.2, "transition":"easeInOutExpo"});
    caurina.transitions.Tweener.addTween(imageItem, {"x":-500, "time":1, "transition":"easeInOutExpo"});
    caurina.transitions.Tweener.addTween(rootBlurMask.getChildByName("moduleBg"), {"width":0, "time":1, "delay":0.3, "transition":"easeInOutExpo", "onComplete":clearBlurBg});
    caurina.transitions.Tweener.addTween(mainBg, {"width":0, "time":1, "delay":0.5, "transition":"easeInOutExpo", "onComplete":removedFromStage});
    return;
    }

    function frame1():*
    {
    caurina.transitions.properties.ColorShortcuts.init();
    caurina.transitions.properties.CurveModifiers.init();
    flash.system.Security.allowDomain("www.youtube.com");
    form.visible = false;
    mainBg.visible = false;
    sideTxt.visible = false;
    imageItem.visible = false;
    xmlLoader = new flash.net.URLLoader();
    xmlLoader.addEventListener(flash.events.Event.COMPLETE, xmlLoaded, false, 0, true);
    xmlLoader.addEventListener(flash.events.IOErrorEvent.IO_ERROR, catchIOError, false, 0, true);
    this.addEventListener(flash.events.Event.ADDED_TO_STAGE, init);
    formLoader = new flash.net.URLLoader();
    phpFileURL = new flash.net.URLRequest("email.php");
    phpFileURL.method = flash.net.URLRequestMethod.POST;
    return;
    }

    public function onCSSFileLoaded(arg1:flash.events.Event):void
    {
    cssloader.removeEventListener(flash.events.Event.COMPLETE, onCSSFileLoaded);
    var loc1:*=new flash.text.StyleSheet();
    loc1.parseCSS(cssloader.data);
    sideTxt.txt.styleSheet = loc1;
    return;
    }

    public function catchIOError(arg1:flash.events.IOErrorEvent):*
    {
    trace("Error caught: " + arg1);
    return;
    }

    public function sendBtnOver(arg1:flash.events.MouseEvent):void
    {
    caurina.transitions.Tweener.addTween(arg1.currentTarget.over, {"width":arg1.currentTarget.bg.width, "time":0.5, "transition":"easeInOutExpo"});
    return;
    }

    public function gotImage(arg1:flash.events.Event):void
    {
    imageLoader.contentLoaderInfo.removeEventListener(flash.events.Event.INIT, gotImage);
    imageLoader.contentLoaderInfo.removeEventListener(flash.events.IOErrorEvent.IO_ERROR, catchIOError);
    var loc1:*=arg1.currentTarget.content;
    imageItem.imageHolder.addChild(loc1);
    if (xml.settings.@url != "")
    {
    imageItem.imageHolder.buttonMode = true;
    imageItem.imageHolder.addEventListener(flash.events.MouseEvent.MOUSE_UP, imageClicked, false, 0, true);
    }
    launch();
    return;
    }

  2. #2
    Join Date
    Aug 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default as3 cont:

    as3 cont:


    public function launch():void
    {
    mainBg.width = 0;
    mainBg.height = stage.stageHeight - 185;
    mainBg.x = (stage.stageWidth - 960) / 2;
    mainBg.y = 140;
    mainBg.visible = true;
    caurina.transitions.Tweener.addTween(mainBg, {"width":520, "time":1, "delay":0.2, "transition":"easeInOutExpo"});
    var loc1:*=new flash.display.Sprite();
    loc1.name = "moduleBg";
    loc1.graphics.beginFill(uint("0xFFFFFF"));
    loc1.graphics.drawRect(0, 0, 480, 120);
    loc1.graphics.endFill();
    loc1.x = (stage.stageWidth - 960) / 2;
    loc1.y = 140;
    loc1.width = 0;
    loc1.height = stage.stageHeight - 185;
    rootBlurMask.addChild(loc1);
    caurina.transitions.Tweener.addTween(rootBlurMask.getChildByName("moduleBg"), {"width":520, "time":1, "transition":"easeInOutExpo"});
    form.y = 440;
    form.x = -520;
    form.visible = true;
    caurina.transitions.Tweener.addTween(form, {"x"stage.stageWidth - 960) / 2 + 20, "time":1, "delay":0.9, "transition":"easeInOutExpo"});
    sideTxt.x = -520;
    sideTxt.y = 160;
    sideTxt.visible = true;
    if (xml.settings.@imagePath == "")
    {
    caurina.transitions.Tweener.addTween(sideTxt, {"x"stage.stageWidth - 960) / 2 + 20, "time":1, "delay":0.5, "transition":"easeInOutExpo"});
    }
    else
    {
    caurina.transitions.Tweener.addTween(sideTxt, {"x"stage.stageWidth - 960) / 2 + 250, "time":1, "delay":0.5, "transition":"easeInOutExpo"});
    }
    if (xml.settings.@imagePath != "")
    {
    imageItem.x = -520;
    imageItem.y = 160;
    imageItem.visible = true;
    caurina.transitions.Tweener.addTween(imageItem, {"x"stage.stageWidth - 960) / 2 + 20, "time":1, "delay":0.7, "transition":"easeInOutExpo"});
    }
    return;
    }

    public function removedFromStage():void
    {
    flash.display.MovieClip(stage.getChildAt(0)).loadSWF(flash.display.MovieClip(stage.getChildAt(0)).curModule);
    return;
    }

    public function resizeHandler(arg1:flash.events.Event):void
    {
    if (rootBlurMask.getChildByName("moduleBg"))
    {
    rootBlurMask.getChildByName("moduleBg").x = (stage.stageWidth - 960) / 2;
    rootBlurMask.getChildByName("moduleBg").y = 140;
    rootBlurMask.getChildByName("moduleBg").height = stage.stageHeight - 185;
    }
    mainBg.x = (stage.stageWidth - 960) / 2;
    mainBg.y = 140;
    mainBg.height = stage.stageHeight - 185;
    form.y = 440;
    form.x = (stage.stageWidth - 960) / 2 + 20;
    if (xml.settings.@imagePath == "")
    {
    sideTxt.x = (stage.stageWidth - 960) / 2 + 20;
    }
    else
    {
    sideTxt.x = (stage.stageWidth - 960) / 2 + 250;
    }
    sideTxt.y = 160;
    if (xml.settings.@imagePath != "")
    {
    imageItem.x = (stage.stageWidth - 960) / 2 + 20;
    imageItem.y = 160;
    }
    return;
    }

    public function clearBlurBg():*
    {
    var loc1:*=rootBlurMask.getChildByName("moduleBg");
    rootBlurMask.removeChild(loc1);
    loc1 = null;
    return;
    }

    public function sendBtnOut(arg1:flash.events.MouseEvent):void
    {
    caurina.transitions.Tweener.addTween(arg1.currentTarget.over, {"width":0, "time":0.5, "transition":"easeInOutExpo"});
    return;
    }

    public function xmlLoaded(arg1:flash.events.Event):void
    {
    xmlLoader.removeEventListener(flash.events.Event.COMPLETE, xmlLoaded);
    xmlLoader.removeEventListener(flash.events.IOErrorEvent.IO_ERROR, catchIOError);
    xml = new XML(arg1.target.data);
    caurina.transitions.Tweener.addTween(mainBg, {"_color":"0x" + xml.settings.@bgColor, "alpha":xml.settings.@bgAlpha, "time":0});
    caurina.transitions.Tweener.addTween(form.inputBg, {"_color":"0x" + xml.settings.@txtFieldsBgColor, "alpha":xml.settings.@txtFieldsBgAlpha, "time":0});
    form.sendBtn.txt.autoSize = flash.text.TextFieldAutoSize.LEFT;
    form.sendBtn.txt.text = xml.settings.@sendLabel;
    caurina.transitions.Tweener.addTween(form.sendBtn.bg, {"_color":"0x" + xml.settings.@sendButtonBgColor, "alpha":xml.settings.@sendButtonBgAlpha, "time":0});
    caurina.transitions.Tweener.addTween(form.sendBtn.over, {"_color":"0x" + xml.settings.@sendButtonBgOverColor, "alpha":xml.settings.@sendButtonBgOverAlpha, "time":0});
    var loc1:*="0x" + xml.settings.@textColor;
    form.sendBtn.txt.textColor = loc1;
    sideTxt.txt.textColor = loc1;
    form.sendBtn.bg.width = form.sendBtn.txt.textWidth + 10;
    form.sendBtn.over.width = 0;
    form.sendBtn.txt.x = (form.sendBtn.bg.width - form.sendBtn.txt.width) / 2;
    form.sendBtn.txt.y = (form.sendBtn.bg.height - form.sendBtn.txt.height) / 2;
    form.sendBtn.x = 470 - form.sendBtn.bg.width;
    form.sendBtn.buttonMode = true;
    form.sendBtn.mouseChildren = false;
    form.sendBtn.addEventListener(flash.events.MouseEvent.ROLL_OVER, sendBtnOver, false, 0, true);
    form.sendBtn.addEventListener(flash.events.MouseEvent.ROLL_OUT, sendBtnOut, false, 0, true);
    form.sendBtn.addEventListener(flash.events.MouseEvent.MOUSE_UP, sendBtnClicked, false, 0, true);
    var loc2:*;
    form.messageLabel.autoSize = loc2 = flash.text.TextFieldAutoSize.LEFT;
    form.subjectLabel.autoSize = loc2 = loc2;
    form.emailLabel.autoSize = loc2 = loc2;
    form.nameLabel.autoSize = loc2;
    form.nameLabel.text = xml.settings.@nameLabel;
    form.emailLabel.text = xml.settings.@emailLabel;
    form.subjectLabel.text = xml.settings.@subjectLabel;
    form.messageLabel.text = xml.settings.@messageLabel;
    form.nameLabel.textColor = loc1;
    form.emailLabel.textColor = loc1;
    form.subjectLabel.textColor = loc1;
    form.messageLabel.textColor = loc1;
    form.nameInput.textColor = loc1;
    form.emailInput.textColor = loc1;
    form.subjectInput.textColor = loc1;
    form.messageInput.textColor = loc1;
    form.errorTxt.textColor = loc1;
    if (xml.settings.@imagePath == "")
    {
    sideTxt.txt.width = 480;
    sideTxt.txt.autoSize = flash.text.TextFieldAutoSize.LEFT;
    sideTxt.txt.htmlText = xml.textBox;
    launch();
    }
    else
    {
    sideTxt.txt.autoSize = flash.text.TextFieldAutoSize.LEFT;
    sideTxt.txt.htmlText = xml.textBox;
    imageLoader = new flash.display.Loader();
    imageLoader.contentLoaderInfo.addEventListener(flash.events.Event.INIT, gotImage, false, 0, true);
    imageLoader.contentLoaderInfo.addEventListener(flash.events.IOErrorEvent.IO_ERROR, catchIOError, false, 0, true);
    imageLoader.load(new flash.net.URLRequest(xml.settings.@imagePath));
    }
    return;
    }

    public function loadCSS():void
    {
    var loc1:*=new flash.net.URLRequest("styleCSS.css");
    cssloader = new flash.net.URLLoader();
    cssloader.addEventListener(flash.events.Event.COMPLETE, onCSSFileLoaded, false, 0, true);
    cssloader.load(loc1);
    return;
    }

    public var form:flash.display.MovieClip;

    public var xmlLoader:flash.net.URLLoader;

    public var imageLoader:flash.display.Loader;

    public var imageItem:flash.display.MovieClip;

    public var cssloader:flash.net.URLLoader;

    public var xml:XML;

    public var sideTxt:flash.display.MovieClip;

    public var mainBg:flash.display.MovieClip;

    public var formTimer:flash.utils.Timer;

    public var rootBlurMask:flash.display.MovieClip;

    public var formLoader:flash.net.URLLoader;

    public var phpFileURL:flash.net.URLRequest;
    }
    }

  3. #3
    Join Date
    Aug 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP Script

    <?php
    $contact_name = $_POST['name'];
    $contact_email = $_POST['email'];
    $contact_subject = $_POST['subject'];
    $contact_message = $_POST['message'];

    if( $contact_name == true )
    {
    $sender = $contact_email;
    $receiver = "support@xxxxxx.com";
    $client_ip = $_SERVER['REMOTE_ADDR'];
    $email_body = "Name: $contact_name \nEmail: $sender \nSubject: $contact_subject \nMessage: $contact_message \nIP: $client_ip ";
    $extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();

    if( mail( $receiver, "Flash Contact Form - $contact_subject", $email_body, $extra ) )
    {
    echo "status=success";
    }
    else
    {
    echo "status=fail";
    }
    }
    ?>

  4. #4
    Join Date
    Aug 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default button script

    package
    {
    import flash.display.*;
    import flash.text.*;

    public dynamic class buttonMc extends flash.display.MovieClip
    {
    public function buttonMc()
    {
    super();
    return;
    }

    public var txt:flash.text.TextField;

    public var over:flash.display.MovieClip;

    public var bg:flash.display.MovieClip;
    }
    }

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    First, please consider trying to make this easy for someone who wants to help you. Posting like that is hard to read and awkward. Use [code] tags for wrap code in a readable way, and if the code is too long for a message then save it as a text file and attach that to your post.
    Second, that is a LOT of code for anyone to debug for free. Do you want an assistant for this (paid) or do you want some reasonable free help? (Of course if someone is willing to help with that, it's great. And there may be a very simple typo or something that is easy to fix, but if this requires debugging all of that, it's not likely that anyone will be willing to take the time for free.)

    Third, please try to do this step by step yourself. Does PHP send emails on your server? Setup an HTML form to test this, or just use hard-coded content in a PHP file to see if emails do work. Once the PHP is working, you know the problem is connected to communication with Flash.

    Finally, aside from the code, you posted very little information. If there is anything else at all that might help us understand what is going on (or give us something to test) that would make it easier. (Right now your post reads essentially "Here's some code that does not work. Why?")

    I realize this may sound harsh, but if you want help, please start by being organized in the way you ask for it and doing as much work as possible yourself-- that way we can easily help you and it's better for everyone.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    First, please consider trying to make this easy for someone who wants to help you. Posting like that is hard to read and awkward. Use [code] tags for wrap code in a readable way, and if the code is too long for a message then save it as a text file and attach that to your post.
    Second, that is a LOT of code for anyone to debug for free. Do you want an assistant for this (paid) or do you want some reasonable free help? (Of course if someone is willing to help with that, it's great. And there may be a very simple typo or something that is easy to fix, but if this requires debugging all of that, it's not likely that anyone will be willing to take the time for free.)

    Third, please try to do this step by step yourself. Does PHP send emails on your server? Setup an HTML form to test this, or just use hard-coded content in a PHP file to see if emails do work. Once the PHP is working, you know the problem is connected to communication with Flash.

    Finally, aside from the code, you posted very little information. If there is anything else at all that might help us understand what is going on (or give us something to test) that would make it easier. (Right now your post reads essentially "Here's some code that does not work. Why?")

    I realize this may sound harsh, but if you want help, please start by being organized in the way you ask for it and doing as much work as possible yourself-- that way we can easily help you and it's better for everyone.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Aug 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks for your post and i will take your advice into consideration when posting future messages.

    my server does allow php. i had a website that i redesigned and this is the script for the contact form. i've went over it again and again and i know there's one little thing i missed that is not sending the message. just some tips that could possibly point me in the right direction would be great.

    Thanks again.

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    That's the first thing: your server supports PHP.

    Next:
    1. Is PHP configured to send emails? It isn't always. Create a test script using PHP (just a single mail() line will be enough) to see if it goes through. If you get this to work, then go back to your current form and try to use it through an HTML form. If all of that works, then you know the problem is not PHP.
    2. You can try to do the same thing but create a response in another way: store the info in a database, write a temporary text file to the server, or something else. Then run the Flash and see if that action is completed. If this works, then you know the problem is within the PHP and related to the mail function (or potentially in how the email info is received from Flash-- something may not be getting through, so you don't have the email address listed or something like that).


    The first step with this sort of thing is to always isolate the problem.

    Note that if you create a new PHP page using only: <?php phpinfo(); ?> you can get a lot of information about your server, including whether a mail server is setup. That does not guarantee it will always work, but if you don't have one setup, it will never work.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •