我创建一个表格。所有输入数据将通过电子邮件发送给管理员。但是,当我单击btn_submit时,它会转到“谢谢”页面,并且没有电子邮件发送给admin。我不确定我在哪里犯了错误!
<?php
require('../db/volunteerCheck.php');
?>
<?php
//---------------Validate Form Data Input--------------------
if(isset($_POST["btn_submit"])){
$first_name = $last_name= $email= $skills = $tell_us_somthing = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$first_name = validate_input($_POST["first_name"]);
$email = validate_input($_POST["email"]);
$last_name = validate_input($_POST["last_name"]);
$skills = validate_input($_POST["skills"]);
$tell_us_somthing = validate_input($_POST["tell_us_somthing"]);
}
function validate_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
//--------------EMAILLING THE FORM INFO--------------------------------
$message_content= "Information about interested person as a volunteer: \n". $first_name."<br>".$last_nam."<br>".$email."<br>".$skills."<br>".$tell_us_somthing;
$email = $_POST["email"];
$to = "shaik027@hrc.com";
$subject = "New volunteer application form info";
$headers = "From: $email\n";
$message = "Thanks for your interest. The information is given as: .\n".$message_content;
$user = $first_name." ".$last_name;
$usersubject = "Thank You";
$userheaders = "From: smak@academic.rrc.ca\n";
$usermessage = "Thank you for your interest.".$message_content;
$success_1 = mail($to,$subject,$message,$headers);
if (!$success_1) {
$errorMessage = error_get_last()['message'];
}
$success_2 = mail($user,$usersubject,$usermessage,$userheaders);
if (!$success_2) {
$errorMessage = error_get_last()['message'];
}}
?>
<!DOCTYPE HTML>
<html class="no-js">
<head>
<meta charset="utf-8">
<?php header('X-UA-Compatible: IE=edge,chrome=1');?>
<title>Join with our Team</title>
</head>
<body>
<div id="resultsbackground">
<div id="volunteer_form">
<form method="post" action="thank_you_form.php">
<label for="first_name">First Name:</label>
<input type="text" id="first_name" name="first_name" placeholder="Your first name" required>
<label for="last_name">Last Name:</label>
<input type="text" id="last_name" name="last_name" placeholder="Your last name" required>
<label for="email">Email:</label>
<input type="text" id="email" name="email" placeholder ="name@mail.com" required>
<label for="skills">Some of your skills:</label>
<input type="text" id="skills" name="skills" placeholder="Optional">
<label for="tell_us_somthing"></label><br/>
<textarea id="tell_us_somthing" name="tell_us_somthing" rows="7" cols="90" placeholder="Tell us somthing, why you want to joing with our team."></textarea><br/>
<input type="submit" id="btn_submit" name="btn_submit">
</form>
</div>
<?php include('../footer/footer.php'); ?>
</div>
</body>
</html>
这不是smtp邮件。我对smtp邮件没有太多了解。所以我使用mail()。
谢谢。