Contact Form Not Working Properly

So I have built a contact form out of AS2 and PHP. PHP 5 is enabled on my server, so that’s not a problem. I think there is a slight error within my code somewhere. What happens is once online, you fill out the form and hit post, it goes to the “error sending email!”. Below is my code so you can take a look at it and help me out. I also have included below that a link to download the actual files. Thanks

<3 Amie


// 
// SET FOCUS FIELDS
//
name_txt.onSetFocus = function() {
    name_mc.gotoAndPlay("write");
    name_title.gotoAndPlay("_white");
    if (this.text == "Name is Required!") {
        this.text = "";
    }
};
phone_txt.onSetFocus = function() {
    phone_mc.gotoAndPlay("write");
    phone_title.gotoAndPlay("_white");
    if (this.text == "Phone Number is Required!") {
        this.text = "";
    }
};
email_txt.onSetFocus = function() {
    email_mc.gotoAndPlay("write");
    email_title.gotoAndPlay("_white");
    if (this.text == "Email is Required!") {
        this.text = "";
    }
};
message_txt.onSetFocus = function() {
    message_mc.gotoAndPlay("write");
    message_title.gotoAndPlay("_white");
    if (this.text == "Message is Required!") {
        this.text = "";
    }
};


//
// KILL FOCUS FIELDS
//
name_txt.onKillFocus = function() {
    name_mc.gotoAndPlay("killFocus");
    name_title.gotoAndPlay("_glowing");
};
phone_txt.onKillFocus = function() {
    phone_mc.gotoAndPlay("killFocus");
    phone_title.gotoAndPlay("_glowing");
};
email_txt.onKillFocus = function() {
    email_mc.gotoAndPlay("killFocus");
    email_title.gotoAndPlay("_glowing");
};
message_txt.onKillFocus = function() {
    message_mc.gotoAndPlay("killFocus");
    message_title.gotoAndPlay("_glowing");
};


//TABS
name_txt.tabIndex = 0;
phone_txt.tabIndex = 1;
email_txt.tabIndex = 2;
message_txt.tabIndex = 3;
send_mc.tabIndex = 4;


//SEND ACTIONS/////////////////////////////////////
///////////////////////////////////////////////////


//ASTERICKS TO MARK WHAT NEEDS TO BE CORRECTED
nameBlank_mc._visible = false;
phoneBlank_mc._visible = false;
emailBlank_mc._visible = false;
messageBlank_mc._visible = false;


//LOADVARS
var senderLoad:LoadVars = new LoadVars();
var receiveLoad:LoadVars = new LoadVars();


//SEND  ON RELEASE FUNCTION
send_mc.onRelease = function():Void {
    send_mc.gotoAndPlay("_release");
    outfxSound.start ();
    //HIDE ASTERICKS IN BEGINNING
    nameBlank_mc._visible = false;
    phoneBlank_mc._visible = false;
    emailBlank_mc._visible = false;
    messageBlank_mc._visible = false;
    //LOAD TEXT FOR SENDERLOAD
    senderLoad.name_txt = name_txt.text;
    senderLoad.phone_txt = phone_txt.text;
    senderLoad.email_txt = email_txt.text;
    senderLoad.message_txt = message_txt.text;
    //IF ANY TEXT FIELD IS BLANK OF INCORRECT, RETURN A FALSE
    if (name_txt.text == "" or name_txt.text == "Name is Required!") {
        name_txt.text = "Name is Required!";
        nameBlank_mc._visible = true;
    } else if (phone_txt.text == ""or phone_txt.text == "Phone Number is Required!") {
        phone_txt.text = "Phone Number is Required!";
        phoneBlank_mc._visible = true;
    } else if (email_txt.text == "" or name_txt.text == "Email is Required!") {
        email_txt.text = "Email is Required!";
        emailBlank_mc._visible = true;
    //IF EMAIL IS INVALID RETURN A FALSE (CODE FOR EMAIL 
    //EMAIL VALIDATION IS LOCATED BELOW
    } else if (email_txt.text.emailValidation() == false) {
        email_txt.text = "Email is Invalid!";
        emailBlank_mc._visible = true;
    } else if (message_txt.text == ""or message_txt.text == "Message is Required!") {
        message_txt.text = "Message is Required!";
        messageBlank_mc._visible = true;
    } else {
        //IF ALL TEXT FIELDS ARE VALID, THEN SEND AND LOAD CONTACT.PHP
        senderLoad.sendAndLoad("contact.php", receiveLoad, "GET");
    }
};

//FUNCTION TO CHECK IF FORM IS SENT
receiveLoad.onLoad = function():Void {
    if (this.sentOk) {
        name_txt.text = "";
        phone_txt.text = "";
        email_txt.text = "";
        message_txt.text = "";
        status_txt.text = "Email Sent. Thanks!";
    } else {
        status_txt.text = "Error Sending Email!";
    }
};


//EMAIL VALIDATION
String.prototype.emailValidation = function() {
    //check to see if atleast 5 characters
    if (this.length < 5) {
        return false;
    }
    //Check to see if there are illegal characters within the email
    invalidChars = "`!#$%^&*()[]{}|:;'\",&lt;&gt;";
    for (i=0; i&lt;this.length; i++) {
        if (invalidChars.indexOf(this.charAt(i)) != -1) {
            return false;
        }
    }
    //Check to see if the symbol @ is present, and 
    //if its in a valid postition
    at = this.lastIndexOf("@");
    if (at&lt;1 || (at == this.length-1)) {
        return false;
    }
    //Check to see if a period is present and if 
    //its in a valid position
    period = this.lastIndexOf(".");
    if (period&lt;4 || (period == this.length-1)) {
        return false;
    }
    //Check to see if the @ symbol and period are 
    //within their valid positions.
    if (1&gt;=period-at) {
        return false;
    }
    //Check to see if there are no two periods or 
    //@ symbols in a row
    for (i=0; i&lt;this.length; i++) {
        if ((this.charAt(i) == "." || this.charAt(i) == "@") && this.charAt(i) == this.charAt(i-1)) {
            return false;
        }
    }
    return true;    
}



//SEND BUTTON
this.send_mc.onRollOver = function() {
    send_mc.gotoAndPlay("_over");
    overfxSound.start ();
}

this.send_mc.onRollOut = function() {
    send_mc.gotoAndPlay("_out");
}

send_mc.tabEnabled=false;
<?PHP
$sendTo = "myemailaddress";
$subject = "Website Contact";

$contact_name = $_GET['name_txt'];
$contact_phone = $_GET['phone_txt'];
$contact_email = $_GET['email_txt'];
$contact_message = $_GET['message_txt'];

$message = "
Name: $contact_name 

Email: $contact_email 

Phone: $contact_phone 


Message: $contact_message";

$headers = "From: $contact_name: $contact_email";
$headers .= "
Reply-To: $contact_email";

mail($sendTo, $subject, $message, $headers);
echo "sentOk=" . $sentOk;
?>

I have added “myemailaddress” above for security purposes.

Here is a download of the files :slight_smile:
http://www.megaupload.com/?d=NDZ0H0AJ