I am currently in the process of pulling out my hair. I have no idea why this code does not work.
I create loadVars to send to a PHP script that in turn sends an email to me with the variable values. The PHP works because when i go to the url that it points to, it sends me a blank email, so i think the actionscript is the problem since i get NO emails when i try to use the contact form.
THanks
Here is the code:
on (release) {
if (_parent.form.name eq "") {
_parent.form.errors = "You forgot to fill in your name!";
} else if (_parent.form.company eq "") {
_parent.form.errors = "You forgot to fill in your company name!";
} else if (_parent.form.email eq "") {
_parent.form.errors = "You forgot to fill in your e-mail address!";
} else if (_parent.form.phone eq "") {
_parent.form.errors = "You forgot to fill in your phone number!";
} else {
mail_vars = new LoadVars();
mail_vars.name = _parent.form.name;
mail_vars.company = _parent.form.company;
mail_vars.email = _parent.form.phone;
mail_vars.comments = _parent.form.comments;
mail_vars.onLoad = function(success) {
if (success) {
_parent.form.errors = "Sent! Thank You!";
// done with contact form..make this point somewhere
} else {
_parent.form.errors = "error with contact form";
}
};
mail_vars.sendAndLoad("http://www.testsite.com/contact.php", mail_vars, "POST");
}
}
and the php
$name= $_POST['name'];
$company= $_POST['company'];
$email= $_POST['email'];
$phone= $_POST['phone'];
$comments= $_POST['comments'];
echo $name;
$message = '
'.$name .'
'. $company .'
'. $email .'
' .$phone. '
---------------------
'. $comments .'
';
mail("email@email.com", "POSSIBLE CLIENT!", $message, "From: email@{$_SERVER['SERVER_NAME']}");
echo "Sent!";