Pulse CMS - Contact Form - php

I have produced a site at "http://missdcall.co.uk" and have included a contact form at the bottom using Pulse CMS.
The contact form continues to return an error stating: "Sorry it seems that our mail server is not responding, Sorry for the inconvenience!"
As far as I can see, all is set-up correctly. I cannot see any errors in the code.
If anyone has any suggestions, they would be greatly appreciated!
Please find relevant files below...
home.txt
<div class="col-sm-6">
<form id="form_1" novalidate>
<div class="form-group">
<label>
Name
</label>
<input id="name" class="form-control" required />
</div>
<div class="form-group">
<label>
Email
</label>
<input id="email" class="form-control" type="email" required />
</div>
<div class="form-group">
<label>
Message
</label><textarea id="message" class="form-control" rows="4" cols="50" required></textarea>
</div>
<button class="bloc-button btn btn-d btn-lg btn-block" type="submit">
Send
</button>
</form>
</div>
form_1.php
<?php
if(empty($_POST['name']) && strlen($_POST['name']) == 0 || empty($_POST['email']) && strlen($_POST['email']) == 0 || empty($_POST['message']) && strlen($_POST['message']) == 0)
{
return false;
}
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = 'hello#missdcall.co.uk'; // Email submissions are sent to this email
// Create email
$email_subject = "Message from miss'd call.";
$email_body = "You have received a new message. \n\n".
"Name: $name \nEmail: $email \nMessage: $message \n";
$headers = "MIME-Version: 1.0\r\nContent-type: text/plain; charset=UTF-8\r\n";
$headers .= "From: joe#j-col.com\n";
$headers .= "Reply-To: $email";
mail($to,$email_subject,$email_body,$headers); // Post message
return true;
?>
formHandler.js
$(function()
{var successMsg = "Your message has been sent."; // Message shown on success.
var failMsg = "Sorry it seems that our mail server is not responding, Sorry for the inconvenience!"; // Message shown on fail.
$("input,textarea").jqBootstrapValidation(
{
preventSubmit: true,
submitSuccess: function($form, event)
{
if(!$form.attr('action')) // Check form doesnt have action attribute
{
event.preventDefault(); // prevent default submit behaviour
var processorFile = "./includes/"+$form.attr('id')+".php";
var formData = {};
$form.find("input, textarea, option:selected").each(function(e) // Loop over form objects build data object
{
var fieldData = $(this).val();
var fieldID = $(this).attr('id');
if($(this).is(':checkbox')) // Handle Checkboxes
{
fieldData = $(this).is(":checked");
}
else if($(this).is(':radio')) // Handle Radios
{
fieldData = $(this).val()+' = '+$(this).is(":checked");
}
else if($(this).is('option:selected')) // Handle Option Selects
{
fieldID = $(this).parent().attr('id');
}
formData[fieldID] = fieldData;
});
$.ajax({
url: processorFile,
type: "POST",
data: formData,
cache: false,
success: function() // Success
{
$form.append("<div id='form-alert'><div class='alert alert-success'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button><strong>"+successMsg+"</strong></div></div>");
},
error: function() // Fail
{
$form.append("<div id='form-alert'><div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button><strong>"+failMsg+"</strong></div></div>");
},
complete: function() // Clear
{
$form.trigger("reset");
},
});
}
},
filter: function() // Handle hidden form elements
{
return $(this).is(":visible");
},
});
});

Related

Ajax PHP contact form not working, Unable to post values

I am trying to build a form for my website but It's not working. I have done all the debug but am unable to identify the issue as everything looks fine. Please find the code below:
JS Code:
// 13. contact form
if ($("#contactForm").length) {
setCsrf();
$("#contactForm").validator().on("submit", function(event) {
if (event.isDefaultPrevented()) {
// handle the invalid form...
submitMSG(false);
} else {
// everything looks good!
event.preventDefault();
submitForm();
}
});
}
function submitForm() {
// Initiate Variables With Form Content
var name = $("#name").val();
var email = $("#email").val();
var comments = $("#comments").val();
var csrfToken = $("#csrfToken").val();
if (csrfToken) {
if (name && email && company && website && description && comments) {
$.ajax({
type: "POST",
url: "/libs/contact-form-process.php",
data: "name=" + name + "&email=" + email + "&comments=" + comments + "&csrfToken=" + csrfToken,
success: function success(text) {
if (text == "success") {
formSuccess();
} else {
submitMSG(false, text);
}
}
});
} else {
submitMSG(false, "Please enter the right information.");
}
} else {
submitMSG(false, "Invalid Token");
}
}
function formSuccess() {
$("#contactForm")[0].reset();
submitMSG(true);
}
function submitMSG(valid, msg) {
if (valid) {
$(".message-box").removeClass('d-none').addClass('d-block ');
$(".message-box div").removeClass('alert-danger').addClass('alert-success').text('Form submitted successfully');
} else {
$(".message-box").removeClass('d-none').addClass('d-block ');
$(".message-box div").removeClass('alert-success').addClass('alert-danger').text('Found error in the form. Please check again.');
}
}
function setCsrf() {
$.ajax({
url: 'libs/csrf.php',
type: "GET",
dataType: "json",
success: function success(data) {
if (data) {
document.getElementById("csrfToken").value = data.csrfToken;
}
},
error: function error(_error) {
console.log("Error " + _error);
}
});
PHP Code (contact-form-process.php)
<?php
session_start();
$errorMSG = "";
$name = $_POST["name"];
$email = $_POST["email"];
$comments = $_POST["comments"];
// CSRF token check
if(empty($_SESSION["csrfToken"]) || ($_SESSION["csrfToken"] !== $_POST["csrfToken"])) {
$errorMSG .= "Invalid Token ";
}
// NAME
if (empty($name)) {
$errorMSG .= "Name is required ";
}
// EMAIL
if (empty($email)) {
$errorMSG .= "Email is required ";
}
// MESSAGE
if (empty($comments)) {
$errorMSG .= "Comments is required ";
}
// change email with your email
$emailTo = "info#****.com";
$subject = "*** Request";
// prepare email body text
$emailBody = " \n Name: ";
$emailBody .= $name;
$emailBody .= "\n";
$emailBody .= "Email: ";
$emailBody .= $email;
$emailBody .= "\n";
$emailBody .= "Additional Comments: ";
$emailBody .= $comments;
$emailBody .= "\n";
// send email
if(empty($errorMSG)) {
if (mail($emailTo, $subject, $emailBody, "From:".$email)){
echo "success";
}
}
else{
echo $errorMSG;
}
?>
HTML Code:
<form action="" method="POST" id="contactForm" class="contact-us-form">
<input type="hidden" name="csrfToken" id="csrfToken" value="" />
<div class="form-row">
<div class="col-md-9 col-12">
<h2>Become our Partner</h2>
<p>Fill out the application below and our team will contact you in 24 hours.</p>
</div>
<div class="col-md-9 col-12">
<div class="form-group">
<input type="text" class="form-control" name="name" id="name" placeholder="Your Name *" required="required">
</div>
</div>
<div class="col-md-9 col-12">
<div class="form-group">
<input type="email" class="form-control" name="email" id="email" placeholder="Your Email *" required="required">
</div>
</div>
<div class="col-md-9 col-12">
<div class="form-group">
<textarea name="comments" id="comments" class="form-control" rows="5" cols="25" placeholder="Add some comments *"></textarea>
</div>
</div>
<div class="col-sm-12 mt-3">
<button type="submit" class="btn btn-brand-01" id="btnContactUs">
Apply Now
</button>
</div>
</div>
</form>
I keep getting the error "Found error in the form. Please check again."
Please help.

XAMPP on windows 10 is not running php

Project structure is as follows
C:\xampp\htdocs\myProject\Documentation
C:\xampp\htdocs\myProject\HTML\css
C:\xampp\htdocs\myProject\HTML\images
C:\xampp\htdocs\myProject\HTML\js
C:\xampp\htdocs\myProject\HTML\videos
C:\xampp\htdocs\myProject\HTML\404.html
C:\xampp\htdocs\myProject\HTML\contact.php
C:\xampp\htdocs\myProject\HTML\index.html
C:\xampp\htdocs\myProject\PSD
I have a contact form in index.html that is controlled by a javascript file. This code stops default form submit, performs error checks and then uses ajax to make a post request to contact.php. The javascript code runs, it detects the php (see the alert in the code below just after the axjax funtion call. The value of d is the php script in the alert, but none of the debug lines in the php code get called and it never returns 'success'.
Here is the form
<form class="form-horizontal" id="phpcontactform">
<div class="control-group">
<input class="input-block-level" type="text" placeholder="Full Name" name="name" id="name">
</div>
<div class="control-group">
<input class="input-block-level" type="email" placeholder="Email ID" name="email" id="email">
</div>
<div class="control-group">
<input class="input-block-level" type="text" placeholder="Mobile Number" name="mobile" id="mobile">
</div>
<div class="control-group">
<textarea class="input-block-level" rows="10" name="message" placeholder="Your Message" id="message"></textarea>
</div>
<div class="control-group">
<p>
<input class="btn btn-danger btn-large" type="submit" value="Send Message">
</p>
<span class="loading"></span> </div>
</form>
here is the javascript
// JavaScript Document
$(document).ready(function() {
$("#phpcontactform").submit(function(e) {
e.preventDefault();
var name = $("#name");
var email = $("#email");
var mobile = $("#mobile");
var msg = $("#message");
var flag = false;
if (name.val() == "") {
name.closest(".control-group").addClass("error");
name.focus();
flag = false;
return false;
} else {
name.closest(".control-group").removeClass("error").addClass("success");
} if (email.val() == "") {
email.closest(".control-group").addClass("error");
email.focus();
flag = false;
return false;
} else {
email.closest(".control-group").removeClass("error").addClass("success");
} if (msg.val() == "") {
msg.closest(".control-group").addClass("error");
msg.focus();
flag = false;
return false;
} else {
msg.closest(".control-group").removeClass("error").addClass("success");
flag = true;
}
var dataString = "name=" + name.val() + "&email=" + email.val() + "&mobile=" + mobile.val() + "&msg=" + msg.val();
$(".loading").fadeIn("slow").html("Loading...");
$.ajax({
type: "POST",
data: dataString,
url: "http://localhost/myProject/HTML/contact.php",
cache: false,
success: function (d) {
alert("d: "+d);
$(".control-group").removeClass("success");
if(d == 'success') // Message Sent? Show the 'Thank You' message and hide the form
$('.loading').fadeIn('slow').html('<font color="green">Mail sent Successfully.</font>').delay(3000).fadeOut('slow');
else
$('.loading').fadeIn('slow').html('<font color="red">Mail not sent.</font>').delay(3000).fadeOut('slow');
}
});
return false;
});
$("#reset").click(function () {
$(".control-group").removeClass("success").removeClass("error");
});
})
And finally here is the php
<?php
echo "<script>console.log('Debug Objects:' );</script>";
$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$mobile = $_REQUEST["mobile"];
$msg = $_REQUEST["msg"];
echo "<script>";
echo "alert('this also works');";
echo "</script>";
$to = "myemail#gmail.com";
if (isset($email) && isset($name) && isset($msg)) {
$subject = $name."sent you a message via Raaga";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: ".$name." <".$email.">\r\n"."Reply-To: ".$email."\r\n" ;
$msg = "From: ".$name."<br/> Email: ".$email ."<br/> Mobile: ".$mobile." <br/>Message: ".$msg;
echo "<script>alert('this maybe works');</script>";
$mail = mail($to, $subject, $msg, $headers);
if($mail)
{
echo 'success';
}
else
{
echo "<script>alert('name:'+$name);</script>";
echo 'failed';
}
}
echo "<script>alert('this finally works');</script>";
?>
I tried moving contact.php to the htdocs root but that didnt work. Have turned off all antivirus and firewalls but that didnt work either. Am at a loss. Thought php was supposed to work out of the box with xampp?
Okay so thanks to ADyson for the help. The issue was not that php isn't running, its that the mail server was not properly configured.

Send php mail with file asynch

This is really making me crazy.
This is the issue, I have X form with some text inputs and one input file. In my script I do a previous validation and after, send it to x.php file who sent the mail and returns a response, after that the page changes depending that response. The issue is the x.php file is no receiving the file by this way.
HTML
<form action="/" method="post" enctype="multipart/form-data" id="hv_form" name="hv_form">
<input type="text" name="name" placeholder="Nombre completo" />
<input type="email" name="email" placeholder="E-mail" />
<input type="text" name="phone" placeholder="Teléfono" />
<input type="file" name="hv_file" id="hv_file" />
<label for="hv_file">
<img src="images/addFile.svg" />
Elige un archivo...
</label>
<button class="submit submit_file trans35" type="submit">Enviar archivo</button>
</form>
JQUERY
function send_file(trigger, dataOrigin) {
// trigger > the button inside form to submit data
// dataOrifin > the form
$(trigger).on( 'click', function(e) {
e.preventDefault();
var error = false,
$name = $(dataOrigin +" [class*='name']").val(),
$email = $(dataOrigin +" [class*='email']").val(),
$phone = $(dataOrigin +" [class*='phone']").val(),
$file = $(dataOrigin +" [id='hv_file']").val();
//Check empty inputs or errors
if($name.length == 0){
var error = true;
$(dataOrigin +" [class*='name']").queue(function(){$(this).addClass('cont_error').dequeue();}).delay(err_wt).queue(function(){$(this).removeClass('cont_error').dequeue();});
} else {
$(dataOrigin +" [class*='name']").removeClass('cont_error');
}
//. . . etc
//Send message and file
if (error == true) {
//do something if previous error
} else if (error == false) {
$.post("send_file.php", $(dataOrigin).serialize(),function(result){
var r = JSON.parse(result);
console.log( r );
if (r[0] == 1) {
// if php file responses "1" means sent
// do something...
console.log( "[HV] "+dataOrigin +": Mensaje enviado");
} else if (r[0] == 0) {
// if php file responses "0" means NOT sent
// do something...
console.log( "[HV] "+ dataOrigin +": Mensaje NO enviado");
}
});
}
PHP CODE
<?php
$email_to = 'xxxx#xxxxxx.com'; //email de la empresa
$business = 'xxxxxx'; //nombre de la empresa
$name = $_POST['name'];
$email_from = $_POST['email'];
$phone = $_POST['phone'];
$file = $_FILES['hv_file'];
//Correo
$headers = "From: Postulacion web <$email_from>" . "\r\n";
$headers .= "Reply-To: $name <$email_from>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8 " . "\r\n";
$headers .= "X-Mailer: PHP/" . phpversion(). "\r\n";
$subject = "$name ha enviado su curriculum"; //Asunto del mensaje
$message_full = "Hello world";
$r;
if(mail($email_to, $subject, $message_full, $headers)){
$r = '1';
} else {
$r = '0';
}
$toSend = [$r, $file ];
echo json_encode($toSend);
?>
But by this way $_FILES (in php file) is always empty, what i'm doing wrong?
And if I remove 'preventDefault' and submit the form naturally by clicking the button, the php file does receive the file!
Pleaaasee help me! I'm full desperate!
I changed up your ajax a bit, but I have a solution that works. In your code, I could not see how you were calling your send_file() function. So I got rid of it and used the button to fire the jquery.
Make sure you have jQuery installed.
You will see some changes in your html as well. Everything gets id's and I changed the button to type="button".
Your going to have to rewrite some of your form validation.
But none the less this work and it should give you a good example to work from. This will work every time you hit the button.
HTML
<form action="/" method="post" enctype="multipart/form-data" id="hv_form" name="hv_form">
<input id="name" type="text" name="name" placeholder="Nombre completo" />
<input id="email" type="email" name="email" placeholder="E-mail" />
<input id="phone" type="text" name="phone" placeholder="Teléfono" />
<input id="hv_file" type="file" name="hv_file" />
<label for="hv_file">
Elige un archivo...
</label>
<button id="sendFile" class="submit submit_file trans35" type="button">Enviar archivo</button>
</form>
jQuery
<script>
$(document).ready(function(){
$('#sendFile').on( 'click', function(e) {
e.preventDefault();
var myForm = new FormData();
myForm.append('name', $('#name').val());
myForm.append('email', $('#email').val());
myForm.append('phone', $('#phone').val());
myForm.append('hv_file', $('#hv_file')[0].files[0]);
$.ajax({
url: 'send_file.php',
type: 'POST',
data: myForm,
success: function (result) {
var r = JSON.parse(result);
console.log( r );
if (r[0] == 1) {
// if php file responses "1" means sent
// do something...
//console.log( "[HV] "+dataOrigin +": Mensaje enviado");
} else if (r[0] == 0) {
// if php file responses "0" means NOT sent
// do something...
//console.log( "[HV] "+ dataOrigin +": Mensaje NO enviado");
}
},
cache: false,
contentType: false,
processData: false
});
});
});
</script>
Your PHP looked ok to me. But you do need to make sure you are validating your post & file in your PHP script to make sure nothing unwanted makes it through.

how get response cross domain ajax

i have this code on server 1
$("#send-mail").click(function () {
var name = $('input#name').val(); // get the value of the input field
var error = false;
if (name == "" || name == " ") {
$('#err-name').show(500);
$('#err-name').delay(4000);
$('#err-name').animate({
height: 'toggle'
}, 500, function () {
// Animation complete.
});
error = true; // change the error state to true
}
var emailCompare = /^([a-z0-9_.-]+)#([da-z.-]+).([a-z.]{2,6})$/; // Syntax to compare against input
var email = $('input#email').val().toLowerCase(); // get the value of the input field
if (email == "" || email == " " || !emailCompare.test(email)) {
$('#err-email').show(500);
$('#err-email').delay(4000);
$('#err-email').animate({
height: 'toggle'
}, 500, function () {
// Animation complete.
});
error = true; // change the error state to true
}
var comment = $('textarea#comment').val(); // get the value of the input field
if (comment == "" || comment == " ") {
$('#err-comment').show(500);
$('#err-comment').delay(4000);
$('#err-comment').animate({
height: 'toggle'
}, 500, function () {
// Animation complete.
});
error = true; // change the error state to true
}
if (error == false) {
var dataString = $('#contact-form').serialize(); // Collect data from form
$.ajax({
url: $('#contact-form').attr('action'),
type: "POST",
data: dataString,
timeout: 6000,
error: function (request, error) {
},
success: function (response) {
response = $.parseJSON(response);
if (response.success) {
$('#successSend').show();
$("#name").val('');
$("#email").val('');
$("#comment").val('');
} else {
$('#errorSend').show();
}
}
});
return false;
}
return false; // stops user browser being directed to the php file
});
then i have this other code on server 2
<?php
include 'functions.php';
if (!empty($_POST)){
$data['success'] = true;
$_POST = multiDimensionalArrayMap('cleanEvilTags', $_POST);
$_POST = multiDimensionalArrayMap('cleanData', $_POST);
//your email adress
$emailTo ="****#hotmail.com"; //"yourmail#yoursite.com";
//from email adress
$emailFrom ="contact#yoursite.com"; //"contact#yoursite.com";
//email subject
$emailSubject = "contacto teklife";
$name = $_POST["name"];
$email = $_POST["email"];
$comment = $_POST["comment"];
if($name == "")
$data['success'] = false;
if (!preg_match("/^[_\.0-9a-zA-Z-]+#([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email))
$data['success'] = false;
if($comment == "")
$data['success'] = false;
if($data['success'] == true){
$message = "NAME: $name<br>
EMAIL: $email<br>
COMMENT: $comment";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html; charset=utf-8" . "\r\n";
$headers = 'From: TEKLIFE <jsparrow#blackpearl.com>' . PHP_EOL .
$headers .= "Reply-to: <$email>".
'X-Mailer: PHP/' . phpversion();
mail($emailTo, $emailSubject, $message, $headers);
$data['success'] = true;
echo json_encode($data);
}
}
and this is the code of the contact form on server 1
<div id="successSend" class="alert alert-success invisible">
<strong>Well done!</strong>Your message has been sent.</div>
<div id="errorSend" class="alert alert-error invisible">There was an error.</div>
<form id="contact-form" method="post" action="http://guara.webposicionamientoweb.com.mx/pluton/php/mail.php">
<div class="control-group">
<div class="controls">
<input class="span12" type="text" id="name" name="name" placeholder="* Your name..." />
<div class="error left-align" id="err-name">Please enter name.</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<input class="span12" type="email" name="email" id="email" placeholder="* Your email..." />
<div class="error left-align" id="err-email">Please enter valid email adress.</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<textarea class="span12" name="comment" id="comment" placeholder="* Comments..."></textarea>
<div class="error left-align" id="err-comment">Please enter your comment.</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<button id="send-mail" class="message-btn">Send message</button>
</div>
</div>
</form>
as you seen i send the post datas to other server,, if i click send on the contact form nothing happens...but the email is send ok... so i need the response so when i click send... the contact form fields are cleared... and the text appears ...message has been sent..
im complete newbee on this codes .. so some help are welcome¡¡
I ran your code through a jsfiddle.
And I got this error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://guara.webposicionamientoweb.com.mx/pluton/php/mail.php. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
In your server code, try adding:
header("Access-Control-Allow-Origin: *");
or replace * with your HTML's domain. This should allow the request to pass through.

How to get "success" with jQuery AJAX email form

I have created a simple email form on a website - Processing it through AJAX using the jQuery library.
I know that the form is working because I am receiving the test email, but I will need for the user to know that their email has sent. Currently, there is no event happening upon success. It should be replacing the form (in div #contactform) with a success message. What am I missing here?
NOTE: I looked at the activity in Safari after submitting the form and it shows my process.php script, but it says "cancelled". Why is it doing this, and could it have something to do with why it is not showing a success message?
Here's my script:
HTML
<div id="contactform">
<form id="churchcontact" action="" method="POST">
<ul>
<li>
<label for="name">Name</label>
<span class="error error_name">Please enter your name</span>
<input id="name" type="text" name="name" />
</li>
<li>
<label for="email">Email</label>
<span class="error error_email">Please enter your email address</span>
<input id="email" type="text" name="email" />
</li>
<li>
<label for="message">Message</label>
<span class="error error_message">Please write a message</span>
<textarea id="message" name="message"></textarea>
</li>
<li>
<input class="formsubmit" type="submit" value="Send" />
<li>
</ul>
</form>
</div>
jQUERY
$(document).ready(function() {
////////////////////////////////////
//// form submit ////
////////////////////////////////////
$('#churchcontact').submit(function() {
////////////////////////////////////
//// validation ////
////////////////////////////////////
$('.error').hide();
//message
var message = $('textarea#message').val();
if(message == '') {
$('.error_message').show();
$('textarea#message').focus();
var errors = 'true';
}
//email
var email = $('input#email').val();
var atpos = email.indexOf("#");
var dotpos = email.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length || email == '') {
$('.error_email').show();
$('input#email').focus();
var errors = 'true';
}
//name
var name = $('input#name').val();
if(name == '') {
$('.error_name').show();
$('input#name').focus();
var errors = 'true';
}
if(errors) {
return false;
} else {
////////////////////////////////////
//// process ////
////////////////////////////////////
var dataString = 'name='+ name + '&email=' + email + '&message=' + message;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "sites/all/modules/custom/churchcontact/process.php",
data: dataString,
success: function() {
$('#contactform').html("success!");
}
});
}
return false;
});
});
PHP (process.php)
$name = $_POST['name'];
$email = $_POST['email'];
$msg = $_POST['message'];
$recipient = '[my email]';
$subject = 'Website Test';
$message = '
Name: ' . $name
. ', Email: ' . $email
. ', Message: ' . $msg;
mail($recipient, $subject, $message, $headers);
in process.php add an echo of mail():
$res = mail($recipient, $subject, $message, $headers);
echo $res; //if $res returns 1 that means mail was sent
ajax success:
...
success: function(data) {
if(data == 1){
message = "success!";
}
else{
message = "Error";
}
$('#contactform').empty().html(message);
}

Categories