-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontactform.php
37 lines (32 loc) · 1.47 KB
/
contactform.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
<?php
// The contact Us Form wont work with Local Host but it will work on Live Server
if(isset($_REQUEST['submit'])) {
// Checking for Empty Fields
if(($_REQUEST['name'] == "") || ($_REQUEST['subject'] == "") || ($_REQUEST['email'] == "") || ($_REQUEST['message'] == "")){
// msg displayed if required field missing
$msg = '<div class="alert alert-warning col-sm-6 ml-5 mt-2" role="alert"> Fill All Fileds </div>';
} else {
$name = $_REQUEST['name'];
$subject = $_REQUEST['subject'];
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];
$mailTo = "[email protected]";
$headers = "From: ". $email;
$txt = "You have received an email from ". $name. ".\n\n".$message;
mail($mailTo, $subject, $txt, $headers);
$msg = '<div class="alert alert-success col-sm-6 ml-5 mt-2" role="alert"> Sent Successfully </div>';
}
}
?>
<!--Start Contact Us Row-->
<div class="col-md-8">
<!--Start Contact Us 1st Column-->
<form action="" method="post">
<input type="text" class="form-control" name="name" placeholder="Name"><br>
<input type="text" class="form-control" name="subject" placeholder="Subject"><br>
<input type="email" class="form-control" name="email" placeholder="E-mail"><br>
<textarea class="form-control" name="message" placeholder="How can we help you?" style="height:150px;"></textarea><br>
<input class="btn btn-primary" type="submit" value="Send" name="submit"><br><br>
<?php if(isset($msg)) {echo $msg; } ?>
</form>
</div> <!-- End Contact Us 1st Column-->