Sending email in PHP using AJAX

1.07K views
0

I m trying to send email through contact page using PHP and Ajax.

The HTML Code
<div class=”row”>
<div class=”col-md-6 form-group”>
<input name=”fullName” id=”fullName” type=”text” class=”form-control” placeholder=”Full Name” required>
</div>
<div class=”col-md-6 form-group”>
<input name=”emailID” type=”email”  id=”emailID” class=”form-control” placeholder=”Email ID” required>
</div>
<div class=”col-md-6 form-group”>
<input name=”mobileNumber” id=”mobileNumber” type=”text” class=”form-control” placeholder=”Mobile Number” required>
</div>
<div class=”col-md-6 form-group”>
<input name=”subject” id=”subject” type=”text” class=”form-control” placeholder=”Subject” required>
</div>
<div class=”col-12 form-group”>
<textarea name=”message” id=”message” class=”form-control” rows=”3″ placeholder=”Message” required></textarea>
</div>
<div class=”col-12″>
<input name=”submit” type=”submit” class=”btn btn-success” value=”Send”>

<div id=”status”></div>
</div>
</div>

The Javascript Code

function sendContact() {
jQuery.ajax({
url: “mail.php”,
data:’fullName=’+$(“#fullName”).val()+’&emailID=’+$(“#emailID”).val()

+’&subject=’+$(“#subject”).val()+’&message=’+$(message).val(),
type: “POST”,
success:function(data){
$(“#status”).html(data);
},
error:function (){}
});
}

htmlAdmin2609 Edited question March 21, 2021
Add a Comment
0

Sending an email using a form (ajax, jquery Lib and PHP)

Check out the demo link and source code.

htmlAdmin2609 Changed status to publish March 26, 2021
Add a Comment
You are viewing 1 out of 1 answers, click here to view all answers.
Write your answer.
close