联系表格不会在按下按钮时提交
Contact form won't submit on button press
正在努力让我的联系表发送。我已经粘贴下面的代码
当我填写表格并按下发送时,没有任何反应。我试过使用按钮而不是输入提交,但仍然没有任何作用。我之前有过这样的表格,但现在我无法发送它。有什么线索吗?
<form id="contact-form" method="post" action="process.php">
<div class="row">
<div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">
<div class="form-group" id="name-field">
<div class="form-input">
<input type="text" class="form-control" id="form-name" name="form-name" placeholder="Full Name">
</div>
</div>
</div>
<div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">
<div class="form-group" id="email-field">
<div class="form-input">
<input type="email" class="form-control" id="form-email" name="form-email" placeholder="Email address">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">
<div class="form-group" id="name-field">
<div class="form-input">
<input type="text" class="form-control" id="form-address" name="form-address" placeholder="Address of the works">
</div>
</div>
</div>
<div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">
<div class="form-group" id="email-field">
<div class="form-input">
<input type="text" class="form-control" id="form-phone" name="form-phone" placeholder="Phone number">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
<div class="form-group" id="phone-field">
<div class="form-input">
<input type="text" class="form-control" id="form-subject" name="form-subject" placeholder="Description of the works required">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
<div class="form-group" id="message-field">
<div class="form-input">
<textarea class="form-control" rows="6" id="form-message" name="form-message" placeholder="Further Information"></textarea>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
<div class="form-group">
<input type="submit" value="SEND FORM" />
</div>
</div>
</div>
</form>
<?php
{
$to = "info@blank.co.uk";
$subject = "Contact Page from ";
$headers = "From: A T L <noreply@blank.co.uk>\r\n";
$headers .= "Reply-To: noreply@blank.co.uk\r\n";
$headers .= "Return-Path: noreply@blank.co.uk\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset: utf8\r\n";
$name = filter_input(INPUT_POST, 'form-name');
$email = filter_input(INPUT_POST, 'form-email');
$address = filter_input(INPUT_POST, 'form-address');
$telephone = filter_input(INPUT_POST, 'form-phone');
$theirSub = filter_input(INPUT_POST, 'form-subject');
$message = filter_input(INPUT_POST, 'form-message');
$message =
"<span style='font-weight: bold;'>Name: </span>"."<br />".$name."<br />"."<br />".
"<span style='font-weight: bold;'>Email: </span>"."<br />".$email."<br />"."<br />".
"<span style='font-weight: bold;'>Address: </span>"."<br />".$address."<br />"."<br />".
"<span style='font-weight: bold;'>Telephone: </span>"."<br />".$telephone."<br />"."<br />".
"<span style='font-weight: bold;'>Email: </span>"."<br />".$email."<br />"."<br />".
"<span style='font-weight: bold;'>Subject: </span>"."<br />".$theirSub."<br />"."<br />".
"<span style='font-weight: bold;'>Message: </span>"."<br />".$message."<br />"."<br />";
mail($to, $subject,"We have received a message via the online form at www.blank.co.uk<br /><br />" .
$message, $headers);
echo "Your message was successfully sent. Please <a href='contact.php'>click here</a> to return to the site.";
?>
<?php }
?>
$message 变量被使用了两次...一次是从表单接收数据,然后你覆盖它?您可能希望为此使用不同的变量。我改成了 $msg.
此外,您有很多不必要的 php 标签。也许尝试像这样更清洁的东西来开始:
<?php
$to = "info@blank.co.uk";
$subject = "Contact Page from ";
$headers = "From: A T L <noreply@blank.co.uk>\r\n";
$headers .= "Reply-To: noreply@blank.co.uk\r\n";
$headers .= "Return-Path: noreply@blank.co.uk\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset: utf8\r\n";
$name = filter_input(INPUT_POST, 'form-name');
$email = filter_input(INPUT_POST, 'form-email');
$address = filter_input(INPUT_POST, 'form-address');
$telephone = filter_input(INPUT_POST, 'form-phone');
$theirSub = filter_input(INPUT_POST, 'form-subject');
$msg = filter_input(INPUT_POST, 'form-message');
$message =
"<span style='font-weight: bold;'>Name: </span>"."<br />".$name."<br />"."<br />".
"<span style='font-weight: bold;'>Email: </span>"."<br />".$email."<br />"."<br />".
"<span style='font-weight: bold;'>Address: </span>"."<br />".$address."<br />"."<br />".
"<span style='font-weight: bold;'>Telephone: </span>"."<br />".$telephone."<br />"."<br />".
"<span style='font-weight: bold;'>Email: </span>"."<br />".$email."<br />"."<br />".
"<span style='font-weight: bold;'>Subject: </span>"."<br />".$theirSub."<br />"."<br />".
"<span style='font-weight: bold;'>Message: </span>"."<br />".$msg."<br />"."<br />";
mail($to, $subject,"We have received a message via the online form at www.blank.co.uk<br /><br />" . $message, $headers);
echo "Your message was successfully sent. Please <a href='contact.php'>click here</a> to return to the site.";
?>
正在努力让我的联系表发送。我已经粘贴下面的代码
当我填写表格并按下发送时,没有任何反应。我试过使用按钮而不是输入提交,但仍然没有任何作用。我之前有过这样的表格,但现在我无法发送它。有什么线索吗?
<form id="contact-form" method="post" action="process.php">
<div class="row">
<div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">
<div class="form-group" id="name-field">
<div class="form-input">
<input type="text" class="form-control" id="form-name" name="form-name" placeholder="Full Name">
</div>
</div>
</div>
<div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">
<div class="form-group" id="email-field">
<div class="form-input">
<input type="email" class="form-control" id="form-email" name="form-email" placeholder="Email address">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">
<div class="form-group" id="name-field">
<div class="form-input">
<input type="text" class="form-control" id="form-address" name="form-address" placeholder="Address of the works">
</div>
</div>
</div>
<div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">
<div class="form-group" id="email-field">
<div class="form-input">
<input type="text" class="form-control" id="form-phone" name="form-phone" placeholder="Phone number">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
<div class="form-group" id="phone-field">
<div class="form-input">
<input type="text" class="form-control" id="form-subject" name="form-subject" placeholder="Description of the works required">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
<div class="form-group" id="message-field">
<div class="form-input">
<textarea class="form-control" rows="6" id="form-message" name="form-message" placeholder="Further Information"></textarea>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
<div class="form-group">
<input type="submit" value="SEND FORM" />
</div>
</div>
</div>
</form>
<?php
{
$to = "info@blank.co.uk";
$subject = "Contact Page from ";
$headers = "From: A T L <noreply@blank.co.uk>\r\n";
$headers .= "Reply-To: noreply@blank.co.uk\r\n";
$headers .= "Return-Path: noreply@blank.co.uk\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset: utf8\r\n";
$name = filter_input(INPUT_POST, 'form-name');
$email = filter_input(INPUT_POST, 'form-email');
$address = filter_input(INPUT_POST, 'form-address');
$telephone = filter_input(INPUT_POST, 'form-phone');
$theirSub = filter_input(INPUT_POST, 'form-subject');
$message = filter_input(INPUT_POST, 'form-message');
$message =
"<span style='font-weight: bold;'>Name: </span>"."<br />".$name."<br />"."<br />".
"<span style='font-weight: bold;'>Email: </span>"."<br />".$email."<br />"."<br />".
"<span style='font-weight: bold;'>Address: </span>"."<br />".$address."<br />"."<br />".
"<span style='font-weight: bold;'>Telephone: </span>"."<br />".$telephone."<br />"."<br />".
"<span style='font-weight: bold;'>Email: </span>"."<br />".$email."<br />"."<br />".
"<span style='font-weight: bold;'>Subject: </span>"."<br />".$theirSub."<br />"."<br />".
"<span style='font-weight: bold;'>Message: </span>"."<br />".$message."<br />"."<br />";
mail($to, $subject,"We have received a message via the online form at www.blank.co.uk<br /><br />" .
$message, $headers);
echo "Your message was successfully sent. Please <a href='contact.php'>click here</a> to return to the site.";
?>
<?php }
?>
$message 变量被使用了两次...一次是从表单接收数据,然后你覆盖它?您可能希望为此使用不同的变量。我改成了 $msg.
此外,您有很多不必要的 php 标签。也许尝试像这样更清洁的东西来开始:
<?php
$to = "info@blank.co.uk";
$subject = "Contact Page from ";
$headers = "From: A T L <noreply@blank.co.uk>\r\n";
$headers .= "Reply-To: noreply@blank.co.uk\r\n";
$headers .= "Return-Path: noreply@blank.co.uk\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset: utf8\r\n";
$name = filter_input(INPUT_POST, 'form-name');
$email = filter_input(INPUT_POST, 'form-email');
$address = filter_input(INPUT_POST, 'form-address');
$telephone = filter_input(INPUT_POST, 'form-phone');
$theirSub = filter_input(INPUT_POST, 'form-subject');
$msg = filter_input(INPUT_POST, 'form-message');
$message =
"<span style='font-weight: bold;'>Name: </span>"."<br />".$name."<br />"."<br />".
"<span style='font-weight: bold;'>Email: </span>"."<br />".$email."<br />"."<br />".
"<span style='font-weight: bold;'>Address: </span>"."<br />".$address."<br />"."<br />".
"<span style='font-weight: bold;'>Telephone: </span>"."<br />".$telephone."<br />"."<br />".
"<span style='font-weight: bold;'>Email: </span>"."<br />".$email."<br />"."<br />".
"<span style='font-weight: bold;'>Subject: </span>"."<br />".$theirSub."<br />"."<br />".
"<span style='font-weight: bold;'>Message: </span>"."<br />".$msg."<br />"."<br />";
mail($to, $subject,"We have received a message via the online form at www.blank.co.uk<br /><br />" . $message, $headers);
echo "Your message was successfully sent. Please <a href='contact.php'>click here</a> to return to the site.";
?>