Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Help with Flash Php contact form

    I have a problem with a Flash template contact form that will not send emails to the recipient. The form allows the user to select from a list of contacts to send the form to.

    Here is the flash action script
    function clearForm() {
    name_txt.text = email_txt.text = phone_txt.text = subject_txt.text = message_txt.text = status_txt.text = "";
    dropdown_mc.selectedItemData = "";
    }
    function checkForm():Boolean {
    var missing:Boolean = false;
    if (dropdown_mc.selectedItemData == "") {
    status_txt.text = "Please Select a Department";
    missing = true;
    } else {
    status_txt.text = "";
    }
    if (name_txt.text == "" || name_txt.text == "Please enter your name") {
    name_txt.text = "Please enter your name";
    missing = true;
    }
    if (email_txt.text.indexOf("@") == -1 || email_txt.text.indexOf(".") == -1 || email_txt.length <= 6 || email_txt.text == "Please enter an email address") {
    email_txt.text = "Please enter an email address";
    missing = true;
    }
    if (message_txt.length <= 10 || message_txt.text == "Please enter a message") {
    message_txt.text = "Please enter a message";
    missing = true;
    }
    if (subject_txt.length <= 5 || subject_txt.text == "Please enter an email subject") {
    subject_txt.text = "Please enter an email subject";
    missing = true;
    }
    // if missing is true, return false
    // otherwise return true
    return missing ? false : true;
    }
    function sendMessage():Void {
    // check whether form has been correctly filled in
    var formOK:Boolean = checkForm();
    // if no problems, process the form and send variables to PHP script
    if (formOK) {
    // Form processing goes here
    message.from = name_txt.text;
    message.to = dropdown_mc.selectedItemData;
    message.email = email_txt.text;
    message.phone = phone_txt.text;
    message.subject = subject_txt.text;
    message.contents = message_txt.text;
    message.sendAndLoad(_parent._parent._parent.contactScriptLocation+"?ck="+ new Date().getTime(), messageSent);
    // display message informing user that email is being sent
    _parent.gotoAndPlay("formout");
    }
    }
    var message:LoadVars = new LoadVars();
    var messageSent:LoadVars = new LoadVars();
    var feedbackfromphp = ""
    messageSent.onLoad = function() {
    if (this.sent == "OK") {
    clearForm();
    _parent.gotoAndPlay("thanks");
    feedbackfromphp = "Thankyou.<br>Your message has been sent";
    } else {
    clearForm();
    _parent.gotoAndPlay("thanks");
    feedbackfromphp = "Sorry your message has not been sent.<br>Please try again later";
    }
    };
    clearForm();
    send_mc.onRelease = function() {
    sendMessage();
    }

    This is the PHP Mailer script

    <?php
    if(isset($_POST['submit'];
    $to = $_POST['to'];
    $subject = 'Website Contact Form Monster Trucks Asia: '.$_POST['subject'];
    $message = 'From: '."\n".$_POST['from']."\n\n";
    $message .= 'Email: '."\n".$_POST['email']."\n\n";
    $message .= 'Phone: '."\n".$_POST['phone']."\n\n";
    $message .= 'Message: '."\n".$_POST['contents']."\n\n";
    $additionalHeaders = "From: ".$_POST[name]."<".$_POST[email].">\n";
    $additionalHeaders .= "Reply-To: ".$_POST[email];
    $OK = mail($to, $subject, $message, $additionalHeaders);
    if ($OK) {
    echo 'sent=OK';
    }
    else {
    echo 'sent=failed&reason='. urlencode('There seems to be a problem with the server. Please try later.');
    }
    ?>

    This is the XML for the contact list

    <?xml version="1.0" encoding="UTF-8"?>
    <dropDownItems defaultTitle="Select a Department to Email">
    <dropDownItem title="General Enquiries" data="me@me.com"/>
    <dropDownItem title="Bookings" data="him@me.com"/>

    </dropDownItems>

    I have removed the actual email addresses for privacy.

    If there is anything else needed please ask and I will provide.

    If some one can point me in the correct direction to get this working it will be a great help.

    Thanks

    Chris

  • #2
    Regular Coder
    Join Date
    Nov 2009
    Location
    Scotland / Glasgow
    Posts
    184
    Thanks
    1
    Thanked 19 Times in 19 Posts
    First off your not passing 'submit' from your flash code. The php scripts checks for this before it does anything else. Since your not passing this the script just stops.
    Secondly there seems to be some issues with your php script

    Code:
    if(isset($_POST['submit'];
    This is not right.
    It should be
    Code:
    if(isset($_POST['submit'])){
    .:To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Glasgow Flasher


  •  

    Tags for this Thread

    Posting Permissions

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