[英]My bootstrap PHP contact form comes back with 404 - File or directory not found
Can anyone help with a php error. 任何人都可以帮助解决PHP错误。 My contact form comes back with
我的联系表会随
404 - File or directory not found 404-找不到文件或目录
This is my form 这是我的表格
<form action="contact.php" class="contact-form" accept-charset="UTF-8" role="form">
<div class="form-group col-md-6">
<label class="sr-only" for="exampleInputEmail1">Your Name: *</label>
<input required type="text" class="form-control" id="inputName" placeholder="Your Name: *">
</div>
<div class="form-group col-md-6">
<label class="sr-only" for="exampleInputEmail1">Email: *</label>
<input required type="email" class="form-control" id="inputEmail1" placeholder="Email: *">
</div>
<div class="clearfix"></div>
<div class="form-group">
<label class="sr-only" for="exampleInputEmail1">Subject:</label>
<input type="text" class="form-control" id="inputName" placeholder="Subject:">
</div>
<div class="form-group">
<textarea required class="form-control" rows="5" placeholder="Message: *"></textarea>
</div>
<button type="submit" class="btn btn-lg btn-primary">Submit</button>
</form>
and this is my PHP 这是我的PHP
<?php
$mail = "jade@------.CO.UK";
if($_POST['message']) {
$message = "<h2>Hello here is a message from ".$_SERVER['SERVER_NAME']."</h2><hr>
<p><strong>Name:</strong> ".$_POST['name']."</p>
<p><strong>Email:</strong> ".$_POST['email']."</p>
<p><strong>Message:</strong> ".$_POST['message']."</p>";
$subject="Premium template message: ".$_POST['subject'];
mail($mail, $subject, $message, "Content-type: text/html; charset=utf-8 \r\n");
echo 'AAAAAAAAAAAAAAA';
}
?>
I'm quite new to this and its driving me crazy. 我对此很陌生,这让我发疯。
Thanks 谢谢
Your form doesn't have a method. 您的表单没有方法。 Since you are posting data, add the POST method in html like this
由于您要发布数据,因此像这样在html中添加POST方法
<form action="contact.php" method="POST" class="contact-form" accept-charset="UTF-8" role="form">
And hope that contact.php is in the same directory as well. 并希望contact.php也位于同一目录中。
Check the proper relative contact.php
file location. 检查正确的相对
contact.php
文件位置。 If you are submiting the form to the same file you are in then just remove action="contact.php"
. 如果要将表单提交到相同的文件中,则只需删除
action="contact.php"
。 Also you need to add method
. 另外,您需要添加
method
。 Here's how it should be. 这应该是这样。 Mark
action
and method
in the below code. 在下面的代码中标记
action
和method
。
<form action="" method="post" class="contact-form" accept-charset="UTF-8" role="form"> <div class="form-group col-md-6"> <label class="sr-only" for="exampleInputEmail1">Your Name: *</label> <input required type="text" class="form-control" id="inputName" placeholder="Your Name: *"> </div> <div class="form-group col-md-6"> <label class="sr-only" for="exampleInputEmail1">Email: *</label> <input required type="email" class="form-control" id="inputEmail1" placeholder="Email: *"> </div> <div class="clearfix"></div> <div class="form-group"> <label class="sr-only" for="exampleInputEmail1">Subject:</label> <input type="text" class="form-control" id="inputName" placeholder="Subject:"> </div> <div class="form-group"> <textarea required class="form-control" rows="5" placeholder="Message: *"></textarea> </div> <button type="submit" class="btn btn-lg btn-primary">Submit</button> </form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.