-
Notifications
You must be signed in to change notification settings - Fork 30
/
contact.php
163 lines (127 loc) · 5.85 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
session_start();
include "includes/db.php";
include "includes/header.php";
?>
<?php
if (isset($_POST['submit'])) {
$to = "captcha.c14@gmail.com";
$subject = $_POST['subject'];
$body = $_POST['body'];
mail($to, $subject, $body);
}
?>
<!-- Navigation -->
<link href="css/form_style.css" rel="stylesheet">
<?php include "includes/navigation.php"; ?>
<!-- Page Content -->
<div class="background">
<div class="container1">
<div class="screen">
<div class="screen-header">
<div class="screen-header-left">
<div class="screen-header-button maximize"></div>
<div class="screen-header-button minimize"></div>
<div class="screen-header-button close1"></div>
</div>
<div class="screen-header-right">
<div class="screen-header-ellipsis"></div>
<div class="screen-header-ellipsis"></div>
<div class="screen-header-ellipsis"></div>
</div>
</div>
<div class="screen-body">
<div class="screen-body-item left">
<div class="app-title">
<span>CONTACT </span>
<span>US</span>
</div>
<div class="app-contact">Always there to help you</div>
</div>
<div class="screen-body-item">
<div class="app-form">
<div class="head">
<form action="" role="form" method="post" id="login-form">
<div class="app-form-group">
<input type="hidden" name="contact_number">
<label for="name" style="color: white;">Name</label>
<input type="text" name="from_name" id="name" class="app-form-control" placeholder="Full Name">
</div>
<div class="app-form-group">
<label for="name" style="color: white;">Email</label>
<input type="email" name="reply_to" id="email" class="app-form-control" placeholder="Email- for reply">
</div>
<div class="app-form-group">
<label for="name" style="color: white;">Subject</label>
<input type="Text" name="subject" id="subject" class="app-form-control" placeholder="Subject">
</div>
<div class="app-form-group message ">
<!-- <input class="app-form-control" placeholder="MESSAGE"> -->
<label for="name" style="color: white;">Message</label>
<textarea name="message" id="message" class="app-form-control" cols="50" rows="5" placeholder="MESSAGE"></textarea>
</div>
<div class="app-form-group buttons">
<input class="app-form-button" id="reset" value="Reset" type="button" name="reset" onclick="clearForm()">
<input type="submit" name="submit" id="btn-login" value="Send" class="app-form-button">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<hr>
<script type='text/javascript' src='https://cdn.jsdelivr.net/npm/emailjs-com@2/dist/email.min.js'></script>
<script type='text/javascript'>
(function() {
// https://dashboard.emailjs.com/admin/integration
emailjs.init('user_ctUkVZSQhl8tJdwn5OV7N');
})();
</script>
<script>
function clearForm() {
const name = document.getElementById('name').value = "";
const email = document.getElementById('email').value = "";
const sub = document.getElementById('subject').value = "";
const msg = document.getElementById('message').value = "";
}
function showError(error, alrt) {
const card = document.querySelector('.app-form');
const head = document.querySelector('.head');
const errordiv = document.createElement('div');
errordiv.className = alrt;
errordiv.appendChild(document.createTextNode(error));
card.insertBefore(errordiv, head);
setTimeout(clearError, 3000);
}
function clearError() {
document.querySelector('.alert').remove();
}
</script>
<script type='text/javascript'>
document.getElementById('login-form').addEventListener('submit', function(event) {
event.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const sub = document.getElementById('subject').value;
const msg = document.getElementById('message').value;
// generate a five digit number for the contact_number variable
if (name != "" && email != "" && sub != "" && msg != "") {
this.contact_number.value = Math.random() * 100000 | 0;
// these IDs from the previous steps
emailjs.sendForm('service_jqqodmg', 'template_3d56csi', this)
.then(function() {
console.log('SUCCESS!');
}, function(error) {
console.log('FAILED...', error);
});
showError('Received! Thanks for your message', 'alert alert-success');
clearForm();
} else {
showError('Fields Cannot be Empty!', 'alert alert-danger');
}
});
</script>
<?php include "includes/footer.php"; ?>