这是我的html和PHP代码,当我提交表单数据时,它将我定位到空白窗口,其中没有报告错误,数据也没有发送到邮件,需要进一步注意我的PHP显示错误和显示启动错误已打开。
HTML
<!-- form start -->
<form action="mail_handler.php" method="post" name="form" class="form-box">
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="name" class="form-control" placeholder="Your Name">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="email" name="email" class="form-control" placeholder="Your Email">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="tel" name="phone" class="form-control" placeholder="Your Phone Number">
</div>
<div class="col-sm-12">
<div class="textarea-message form-group">
<textarea name="msg" class="textarea-message form-control" placeholder="Your Message" rows="5">
</textarea>
</div>
</div>
<div class="text-center">
<button type="submit" class="load-more-button">submit
</button>
</div>
</form>
PHP
<?php
if(isset($_POST['submit']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$msg=$_POST['msg'];
$to='xyz@gmail.com';
$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>Sent Successfully! Thank you"." ".$name.", We will contact you shortly!</h1>";
}
else
{
echo "Something went wrong!";
}
}
?>
答案 0 :(得分:0)
在按钮输入中添加name="submit"
答案 1 :(得分:0)
而不是
<button type="submit" class="load-more-button">submit
</button>
使用
<button type="submit" name="submit" class="load-more-button">submit
</button>
请注意添加的name="submit"