当访客提交表单时,我从表单发送邮件。现在电子邮件工作正常。我如何向提交表单的人发送邮件意味着同时自动回复访客电子邮件 ID。请帮我做。
这是我的代码。
<form name="form1" onsubmit="return submitdata()" method="post" >
<fieldset>
<div class="col-xs-6">
<input class="form-control input-sm" type="text" name="name" placeholder="Full Name"required />
</div>
<div class="col-xs-6">
<input class="form-control input-sm" type="email" pattern="[^ @]*@[^ @]*" name="emailid" placeholder="Enter your email"required/>
</div>
<div class="col-xs-6">
<input class="form-control input-sm"type="text" name="phone" placeholder="Phone" required />
</div>
<div class="col-xs-6">
<input class="form-control input-sm" type="text" name="city" placeholder="City"required/>
</div>
<div class="col-xs-6">
<select id="mark" name="mark" class="form-control">
<option>Select Department</option>
<option value="fashion">FASHION DESIGN</option>
<option value="interior">INTERIOR DESIGN</option>
</select>
</div>
<div class="col-xs-6">
<select id="series" class="form-control" name="series">
<option class="fashion" value="">Select Courses</option>
<optgroup class="fashion" label="University Courses" >
<option value="MSc:Fashion Design(2 Years)" class="fashion">MSc: Fashion Design(2 Years)</option>
<option value="BSc:Fashion Design ( 3 Years)" class="fashion">BSc: Fashion Design ( 3 Years)</option>
<option value="Advanced Diploma:Fashion Design ( 2 Years)" class="fashion">Advanced Diploma: Fashion Design ( 2 Years)</option>
<option value="Diploma:Fashion Design (1 Year)" class="fashion">Diploma: Fashion Design (1 Year)</option>
</optgroup>
<optgroup class="fashion" label="IMB (Milan,Italy) Courses">
<option value="Specialisation Program: Fashion Design (3 Years)" class="fashion">Specialisation Program: Fashion Design (3 Years)</option>
<option value="Advanced Program: Fashion Design ( 2 Years)" class="fashion">Advanced Program: Fashion Design ( 2 Years)</option>
<option value="Foundation Program: Fashion Design ( 1 Year) " class="fashion">Foundation Program: Fashion Design ( 1 Year)</option>
</optgroup>
<option value="MSc:Interior Design(2 Years)" class="interior">MSc:Interior Design(2 Years)</option>
<option value="BSc:Interior Design ( 3 Years)" class="interior">BSc:Interior Design ( 3 Years)</option>
<option value="Advanced Diploma:Interior Design ( 2 Years)" class="interior">Advanced Diploma: Interior Design ( 2 Years)</option>
<option value="Diploma:Interior Design (1 Year)" class="interior">Diploma:Interior Design (1 Year)</option>
</select>
</div>
<div class="col-xs-6 ">
<textarea class="form-control input-sm" type="text" name="AcademicQualification" placeholder="Academic Qualification"required></textarea>
</div>
<div class="col-xs-6">
<textarea class="form-control input-xs" rows="2" cols="20" name="comments" placeholder="Comments"required></textarea>
</div>
<div class="col-xs-12">
<button type="submit" class="btn btn-info btn-md" name="submit" value="Send" onclick="submitForm()">Send</button>
</div>
</fieldset>
</form>
<?php
if(isset($_POST['submit']))
{
$message=
'Name : ' .$_POST['name'].' <br />
Email : ' .$_POST['emailid'].' <br />
Phone : ' .$_POST['phone'].' <br />
City : ' .$_POST['city'].' <br />
Interested in : ' .$_POST['mark'].' <br />
Selected Courses: ' .$_POST['series'].' <br />
Academic Qualification: ' .$_POST['AcademicQualification'].' <br />
Comments : '.$_POST['comments'].' <br />
';
require "phpmailer/class.phpmailer.php"; //include phpmailer class
// Instantiate Class
$mail = new PHPMailer();
// Set up SMTP
$mail->IsSMTP(); // Sets up a SMTP connection
$mail->SMTPAuth = true; // Connection with the SMTP does require authorization
$mail->SMTPSecure = "ssl"; // Connect using a TLS connection
$mail->Host = "smtp.gmail.com"; //Gmail SMTP server address
$mail->Port = 465; //Gmail SMTP port
$mail->Encoding = '7bit';
// Authentication
$mail->Username = "jaganrao44@gmail.com"; // Your full Gmail address
$mail->Password = "xxxxxxxxxx"; // Your Gmail password
// Compose
$mail->Subject = "New Admission Enquiry Form"; // Subject (which isn't required)
$mail->MsgHTML($message);
// Send To
$mail->AddAddress("jaganrao44@gmail.com", "Recipient Name"); // Where to send it - Recipient
$result = $mail->Send(); // Send!
$message = $result ? 'Successfully Sent!' : 'Sending Failed!';
}
?>