1<?php
2if(isset($_POST['submit'])){
3 $to = "email@example.com"; // this is your Email address
4 $from = $_POST['email']; // this is the sender's Email address
5 $first_name = $_POST['first_name'];
6 $last_name = $_POST['last_name'];
7 $subject = "Form submission";
8 $subject2 = "Copy of your form submission";
9 $message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
10 $message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];
11
12 $headers = "From:" . $from;
13 $headers2 = "From:" . $to;
14 mail($to,$subject,$message,$headers);
15 mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
16 echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
17 // You can also use header('Location: thank_you.php'); to redirect to another page.
18 }
19?>
20
21<!DOCTYPE html>
22<head>
23<title>Form submission</title>
24</head>
25<body>
26
27<form action="" method="post">
28First Name: <input type="text" name="first_name"><br>
29Last Name: <input type="text" name="last_name"><br>
30Email: <input type="text" name="email"><br>
31Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
32<input type="submit" name="submit" value="Submit">
33</form>
34
35</body>
36</html>
1
2<!DOCTYPE html>
3<html>
4<head>
5<title>FeedBack Form With Email Functionality</title>
6<link href="css/elements.css" rel="stylesheet">
7</head>
8<!-- Body Starts Here -->
9<body>
10<div class="container">
11<!-- Feedback Form Starts Here -->
12<div id="feedback">
13<!-- Heading Of The Form -->
14<div class="head">
15<h3>FeedBack Form</h3>
16<p>This is feedback form. Send us your feedback !</p>
17</div>
18<!-- Feedback Form -->
19<form action="#" id="form" method="post" name="form">
20<input name="vname" placeholder="Your Name" type="text" value="">
21<input name="vemail" placeholder="Your Email" type="text" value="">
22<input name="sub" placeholder="Subject" type="text" value="">
23<label>Your Suggestion/Feedback</label>
24<textarea name="msg" placeholder="Type your text here..."></textarea>
25<input id="send" name="submit" type="submit" value="Send Feedback">
26</form>
27<h3><?php include "secure_email_code.php"?></h3>
28</div>
29<!-- Feedback Form Ends Here -->
30</div>
31</body>
32<!-- Body Ends Here -->
33</html>
34Copy