【发布时间】:2018-03-02 14:50:07
【问题描述】:
<form method="post" action="mail_handler.php">
<div class="col-sm-7 slideanim">
<div class="row">
<div class="col-sm-6 form-group">
<input class="form-control" id="name" name="name" placeholder="Naam" type="text" required>
</div>
<div class="col-sm-6 form-group">
<input class="form-control" id="phone" name="phone" placeholder="Telefoonnummer" type="text" required>
</div>
<div class="col-sm-12 form-group">
<input class="form-control" id="email" name="email" placeholder="Email" type="email" required>
</div>
</div>
<textarea class="form-control" id="msg" name="msg" placeholder="Bericht" rows="5"></textarea><br>
<div class="row">
<div class="col-sm-12 form-group">
<button class="btn btn-default pull-right" id="submit" type="submit">Verstuur</button>
</div>
</div>
</div>
</div>
</div>
</form>
我试图让这个表单工作,但由于某种原因它只是不发送电子邮件,而且在我按下提交按钮后它也保持空白。我已经尽我所能尝试修复它,它一定是我一直忽略的非常明显的东西。 (我与 Cpanel 一起检查邮件是否正在发送,因此有一个 smtp 服务器可用)。
<?php
if(isset($_POST['submit'])){
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$msg=$_POST['msg'];
$to='info@sync-development.nl'; // Receiver Email ID, Replace with your email ID
$subject='Form Submission';
$message="Name :".$name."\n"."Phone :".$phone."\n"."Wrote the following :"."\n\n".$msg;
$headers="From: ".$email;
if(mail($to, $subject, $message, $headers)){
echo "<h1>Bedankt voor uw bericht!"." ".$name.", Wij nemen zo snel mogelijk contact met u op.</h1>";
}
else{
echo "Er is iets fout gegaan, probeer het alstublieft opnieuw.";
}
}
?>
【问题讨论】:
-
您的提交按钮没有名称属性
name="submit"