因此,当我发送带有表单(POST)的电子邮件时,我可以很好地发送电子邮件,但是当我收到它时它是空白的(除了在 php 中定义的部分。就像它没有收到我的 POST 数据一样,当我知道它是。
PHP:
$parentName = strip_tags($_POST['parentName']);
$studentName = strip_tags($_POST['studentName']);
$grade = strip_tags($_POST['grade']);
$message = strip_tags($_POST['message']);
$to = "email@email.com";
$subject = "Message From, ".$parentName;
$message = "Student: ".$studentName."Grade: ".$grade."\r\n".$message;
$from = "Message System";
$headers = "From:" . $parentName;
mail($to,$subject,$message,$headers);
HTML:
<form class="form-horizontal" method="POST" action="php/syst.php" role="form">
<div class="form-group">
<label for="parentName" class="col-sm-5 control-label">Parent Name</label>
<div class="col-sm-7"><input type="text" class="form-control" id="parentName" name="parentName" placeholder="John Doe"></div>
</div>
<div class="form-group">
<label for="studentName" class="col-sm-5 control-label">Student Name</label>
<div class="col-sm-7"><input type="text" class="form-control" id="studentName" name="studentName" placeholder="John Doe"></div>
</div>
<div class="form-group">
<label for="grade" class="col-sm-5 control-label">Grade</label>
<div class="col-sm-7"><input type="text" class="form-control" id="grade" name="grade" placeholder="9 - 12"></div>
</div>
<div class="form-group">
<label for="message" class="col-sm-5 control-label">Message</label>
<div class="col-sm-7"><textarea class="form-control" id="message" name="message"></textarea></div>
</div>
<div class="form-group"><div class="col-sm-offset-2 col-sm-10">
<center>
<div class="opit">
<img id="loading" src="png/loa.gif">
<button type="submit" id="send" class="btn btn-info">Send</button>
</div>
</center>
</div>
</div>
</form>