My problem is that I have a form made with HTML, PHP and AJAX that I went up to my page does everything like "should" but my email does not get the message, I leave my code for review:
HTML:
<h3>Formulario de Contacto</h3>
<div id="note"></div>
<div id="fields">
<form id="ajax-contact-form" action="javascript:alert('success!');">
<div class="left">
<input type="text" name="name" placeholder="Nombres Completos:" >
<div class="clear"></div>
<input type="text" name="email" placeholder="Su Correo:" >
<div class="clear"></div>
<input type="text" name="phone" placeholder="Número de Teléfono">
<div class="clear"></div>
<div class="">
<div class="left">
<input class="capthca" type="text" name="capthca" value="Capthca:" onBlur="if(this.value=='') this.value='Capthca:'" onFocus="if(this.value =='Capthca:' ) this.value=''">
<div class="clear"></div>
<button type="submit" class="submit">submit</button>
</div>
<img src="captcha/captcha.php">
<div class="clear"></div>
</div>
</div>
<div class="left pad_left2">
<textarea name="content" placeholder="Mensaje"></textarea>
<div class="clear"></div>
</div>
<div class="clear"></div>
</form>
</div>
</div>
PHP:
<?php
include 'contact_config.php';
session_start();
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
if($post)
{
include 'functions.php';
$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$phone = stripslashes($_POST['phone']);
$subject = stripslashes($_POST['subject']);
$message = "Site visitor information:
Name: ".$_POST['name']
."
E-mail Address: ".$_POST['email']
."
Phone: ".$_POST['phone']
."
Message: ".$_POST['content'];
$error = '';
// Check name
if(!$name)
{
$error .= 'Please enter your First name.<br />';
}
// Check email
if(!$email)
{
$error .= 'Please enter an e-mail address.<br />';
}
if($email && !ValidateEmail($email))
{
$error .= 'Please enter a valid e-mail address.<br />';
}
if(isset($_SESSION['captcha_keystring']) && strtolower($_SESSION['captcha_keystring']) != strtolower($_POST['capthca']))
{
$error .= "Incorect captcha.<br />";
}
if(!$error)
{
$mail = mail(WEBMASTER_EMAIL, $subject, $message,
"From: ".$name." <".$email.">\r\n"
."Reply-To: ".$email."\r\n"
."X-Mailer: PHP/" . phpversion());
if($mail)
{
echo 'OK';
}
}
else
{
echo '<div class="notification_error">'.$error.'</div>';
}
}
?>
JQUERY - AJAX
$(document).ready(function(){
$("#ajax-contact-form").submit(function(){
var str = $(this).serialize();
$.ajax( { type: "POST", url: "contact.php", data: str, success: function(msg){
if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
{ result = '<div class="notification_ok">Your message has been sent. Thank you!<br> <a href="#" onclick="freset();return false;">send another mail</a></div>'; $("#fields").hide(); }
else
{ result = msg; }
$("#note").html(result);
}
});
return false;
});
});
function freset(){
$("#note").html('');
document.getElementById('ajax-contact-form').reset();
$("#fields").show();
};
aside there is another doc .js
<?php
// To
define( '[email protected]', '[email protected]');
?>