感谢您回答我之前的查询,但我又被叫停了,因为我不知道我遗漏了什么或哪里错了。这是我制作的HTML表单:
<div class="container">
<span class="reg"> <h1>Register Now</h1> </span>
<div class="row">
<div class="conent-part">
<div class="form-body">
<div class="fome-body">
<form id="form" action="/sendform.php" method="post">
<div class="row">
<div class="form-part">
<div class="form-group">
<input type="text" class="form-control" name="name" id="name" placeholder="Your Name">
</div>
<div class="form-group">
<input type="email" class="form-control" name="email" id="email" placeholder="Your Email Address">
</div>
<div class="form-group">
<input type="text" class="form-control" name="nname" id="nname" placeholder="Nominee's Name">
</div>
<div class="form-group">
<input type="email" class="form-control" name="nemail" id="nemail" placeholder="Nominee's Email">
</div>
</div>
<div class="form-part">
<div class="form-group">
<input type="text" class="form-control" name="nsport" id="nsport" placeholder="Nominee's Sport">
</div>
<div class="form-group">
<textarea class="form-control" rows="3" name="accomplishments" id="accomplishments" placeholder="Accomplishments"></textarea>
</div>
</div>
</div>
<div class="custom_btn">
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
这是我刚刚制作的sendform.php代码,但它不会发布,它只是转到sendform.php的空白页。
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$nname = $_POST['nname'];
$nemail = $_POST['nemail'];
$nsport = $_POST['nsport'];
$message = $_POST['accomplishments'];
$from = $from = $email;
$to = 'tempbiz@mail-central.com';
$subject = 'Athlete of the Week - Nomination';
$body = "From: $name'n Email: $email'n Nominee's Name: $nname'n Nominee's Email: $nemail'n Nominee's Nominee's Sport: $nsport'n Accomplishments:'n $accomplishments";
?>
<?php
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your Nomination has been Successfully Sent!</p>';
} else {
echo '<p>Oops! An error occurred. Try sending your Nomination again.</p>';
}
}
?>
您应该检查浏览器在POST
数据中添加的提交名称。
更改:
if ($_POST['submit']) {
对此:
if (isset($_POST['submit'])) {
表单中没有名为"submit"的输入,因此您的邮件发送块永远不会执行。您必须添加"提交"输入。I.e:
<input type="hidden" name="submit" value="1" />