<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.";
}
}
&GT;
答案 0 :(得分:4)
您应该为按钮添加name属性,以替换
<button class="btn btn-default pull-right" id="submit" type="submit">Verstuur</button>
通过
<button class="btn btn-default pull-right" id="submit" name="submit" type="submit">Verstuur</button>`
答案 1 :(得分:0)
试试这个
<button class="btn btn-default pull-right" name="submit" id="submit" type="submit">Verstuur</button>
答案 2 :(得分:0)
<button class="btn btn-default pull-right" id="submit" type="submit">Verstuur</button>
您缺少名称属性, php处理程序未进入if true 条件,因为它无法找到< em>“提交”键。像这样更改 HTML按钮:
<button class="btn btn-default pull-right" id="submit" name="submit" type="submit">Verstuur</button>
答案 3 :(得分:0)
您可以添加名称=&#34;&#34;属性为按钮或中继其他一些var。另外,使用!empty()
仔细检查传递的变量不是空字符串。
所以替换:
if(isset($_POST['submit'])){
使用:
if (!empty($_POST['email'])){
或简单地说:
if (!empty($_POST)){