Form

  • Lghtning4u
  • Born
  • Born
  • Lghtning4u
  • Posts: 4
  • Loc: La Porte, Texas

Post 3+ Months Ago

I know this can't be this hard but can anyone tell me why my contact form will not work? What am I missing here?

Actionscript
Code: [ Select ]
onClipEvent (load) {

var contact_php_file = "flashEmailer.php";

send_btn.onRelease = function() {
    checkForm();
}

function validateEmail(address) {
    // Check address length
    if(address.length >= 7) {
        // Check for an @ sign
        if(address.indexOf("@") > 0) {
            // Check for at least 2 characters following the @
            if((address.indexOf("@") + 2)<address.lastIndexOf(".")) {
                // Check for a domain name of at least 2 characters
                if (address.lastIndexOf(".") < (address.length - 2)) {
                    // If all the above tests pass, the email address is in valid format
                    return true;
                }
            }
        }
    }
    // Called if the email fails
    trace("The entered email address is invalid.");
    return false;
}

function checkForm() {
    n = form.name_txt.text;
    e = form.email_txt.text;
    m = form.msg_txt.text;
    if(m != "" && e != "" && validateEmail(e)) {
        sendEmail(n, e, m);
    } else {
        trace("All Required Fields Not Filled In!");
    }
}

function sendEmail(n, e, m) {
    session = "?nocache=" + random(999999);
    contact_lv = new LoadVars();
    contact_lv.name = n;
    contact_lv.email = e;
    contact_lv.message = m;
    contact_lv.key = "email";
    trace(n + " - " + e + " - " + m);
    contact_lv.sendAndLoad(contact_php_file + session, contact_lv, "POST");
    contact_lv.onLoad = function(success) {
        if(!success) {
            return trace("Error calling PHP File!");
        } else {
            return trace("Email Sent!");
        }            
    }
}

stop();
}
  1. onClipEvent (load) {
  2. var contact_php_file = "flashEmailer.php";
  3. send_btn.onRelease = function() {
  4.     checkForm();
  5. }
  6. function validateEmail(address) {
  7.     // Check address length
  8.     if(address.length >= 7) {
  9.         // Check for an @ sign
  10.         if(address.indexOf("@") > 0) {
  11.             // Check for at least 2 characters following the @
  12.             if((address.indexOf("@") + 2)<address.lastIndexOf(".")) {
  13.                 // Check for a domain name of at least 2 characters
  14.                 if (address.lastIndexOf(".") < (address.length - 2)) {
  15.                     // If all the above tests pass, the email address is in valid format
  16.                     return true;
  17.                 }
  18.             }
  19.         }
  20.     }
  21.     // Called if the email fails
  22.     trace("The entered email address is invalid.");
  23.     return false;
  24. }
  25. function checkForm() {
  26.     n = form.name_txt.text;
  27.     e = form.email_txt.text;
  28.     m = form.msg_txt.text;
  29.     if(m != "" && e != "" && validateEmail(e)) {
  30.         sendEmail(n, e, m);
  31.     } else {
  32.         trace("All Required Fields Not Filled In!");
  33.     }
  34. }
  35. function sendEmail(n, e, m) {
  36.     session = "?nocache=" + random(999999);
  37.     contact_lv = new LoadVars();
  38.     contact_lv.name = n;
  39.     contact_lv.email = e;
  40.     contact_lv.message = m;
  41.     contact_lv.key = "email";
  42.     trace(n + " - " + e + " - " + m);
  43.     contact_lv.sendAndLoad(contact_php_file + session, contact_lv, "POST");
  44.     contact_lv.onLoad = function(success) {
  45.         if(!success) {
  46.             return trace("Error calling PHP File!");
  47.         } else {
  48.             return trace("Email Sent!");
  49.         }            
  50.     }
  51. }
  52. stop();
  53. }


php
Code: [ Select ]
<?php
$recipients = "customerservice@mydomain.com" . ",";
$subject = "The Message";

// Grab the key from Flash to ensure security
$sendKey = $_POST['key'];

// Only allow the page to send if Flash is the requester
if($sendKey == "email") {
    // The following three variables are gathered from Flash
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    
    // Grab todays date
    $date = date("F j, Y", time());

    // This block is the actual message that is sent in the email
    $email_info .= "this message has been sent you your from your e-broucher.\n\n";
    $email_info .= "-----------------------------------------\n";
    $email_info .= "Name: " . $name . "\n";
    $email_info .= "Email: " . $email . "\n";
    $email_info .= "Date Sent: " . $date . "\n\n";
    $email_info .= "Message\n";    
    $email_info .= "-----------------------------------------\n";
    $email_info .= "" . $message . "\n";

    $mailheaders = "From: customerservice@mydomain.com <> \n";
    $mailheaders .= "Reply-To: " . $email . "\n\n";

    if(mail($recipients, $subject, $email_info, $mailheaders)) {
        // Print a success for Flash to know the email is being sent
        print "&success=true";
    }
}

?>
  1. <?php
  2. $recipients = "customerservice@mydomain.com" . ",";
  3. $subject = "The Message";
  4. // Grab the key from Flash to ensure security
  5. $sendKey = $_POST['key'];
  6. // Only allow the page to send if Flash is the requester
  7. if($sendKey == "email") {
  8.     // The following three variables are gathered from Flash
  9.     $name = $_POST['name'];
  10.     $email = $_POST['email'];
  11.     $message = $_POST['message'];
  12.     
  13.     // Grab todays date
  14.     $date = date("F j, Y", time());
  15.     // This block is the actual message that is sent in the email
  16.     $email_info .= "this message has been sent you your from your e-broucher.\n\n";
  17.     $email_info .= "-----------------------------------------\n";
  18.     $email_info .= "Name: " . $name . "\n";
  19.     $email_info .= "Email: " . $email . "\n";
  20.     $email_info .= "Date Sent: " . $date . "\n\n";
  21.     $email_info .= "Message\n";    
  22.     $email_info .= "-----------------------------------------\n";
  23.     $email_info .= "" . $message . "\n";
  24.     $mailheaders = "From: customerservice@mydomain.com <> \n";
  25.     $mailheaders .= "Reply-To: " . $email . "\n\n";
  26.     if(mail($recipients, $subject, $email_info, $mailheaders)) {
  27.         // Print a success for Flash to know the email is being sent
  28.         print "&success=true";
  29.     }
  30. }
  31. ?>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Tannu4u
  • Proficient
  • Proficient
  • User avatar
  • Posts: 480
  • Loc: India

Post 3+ Months Ago

Please specify what's the error you are getting?

Post Information

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