-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.php
74 lines (71 loc) · 2.36 KB
/
contact.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php include('include/currentPage_header.php') ?>
<section id="contact ">
<div class="container-xl mb-5 p-5">
<div class="row">
<div class="col-md-8 mx-auto">
<div class="message"></div>
<div class="contact-form">
<h1>Contact Us</h1>
<p class="hint-text">We'd love to hear from you, please drop us a line if you've any query.</p>
<form id="contact-form" action="functions.php" method="post" autocomplete="off">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="inputFirstName">First Name</label>
<input type="text" class="form-control" id="FirstName" name="FirstName" required>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="inputLastName">Last Name</label>
<input type="text" class="form-control" id="LastName" name="LastName" required>
</div>
</div>
</div>
<div class="form-group">
<label for="inputEmail">Email Address</label>
<input type="email" class="form-control" id="Email" name="Email" required>
</div>
<div class="form-group">
<label for="inputMessage">Message</label>
<textarea class="form-control" id="Message" name="Message" rows="5" required></textarea>
</div>
<button type="submit" class="btn btn-primary" name = "contact" > Submit </button>
</form>
</div>
</div>
</div>
</section>
<script>
$(document).ready(function(){
$('#contact-form').on('submit',function(e){
e.preventDefault();
var formData = new FormData(this);
$.ajax({
url:"functions.php",
type:"POST",
data:formData,
cache:false,
contentType: false,
processData: false,
success:function(data){
console.log("data");
console.log(data);
var json = JSON.parse(data);
if(json['error']!=""){
$('.message').html(`<div class="alert alert-danger" role="alert"> ${json['error']} </div>`);
$('#contact-form')[0].reset();
}else{
$('.message').html(`<div class="alert alert-success" role="alert"> ${json['msg']} </div>`);
$('#contact-form')[0].reset();
}
},
error: function(data){
console.log("error");
console.log(data);
}
});
})
})
</script>
<?php include('include/footer.php')?>