**已解决:现在提交给自己工作。**
我简单的html / php(bootstrap)表单拒绝提交给自己。你能看到我的代码有什么问题吗?我已经尝试了明显的$ _SERVER ['PHP_SELF']和其他一些失败。出于想法。
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div class="row">
<div class="col-lg-12">
<h2>Contact us!</h2>
<!-- changed this
<form name="enquiryform" method="post" action="">
<form class="form-horizontal">
-->
<!-- to this: --> <form class="form-horizontal" name="enquiryform" method="post" action="">
<div class="form-group-lg">
<label class="control-label col-xs-4" for="first_name">Name *</label>
<div class="col-xs-8">
<input type="text" class="form-control" id="name" placeholder="First name" name="first_name" required>
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="last_name">Surname</label>
<div class="col-xs-8">
<input type="text" class="form-control" id="surname" placeholder="Last name" name="last_name">
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="inputEmail">Email *</label>
<div class="col-xs-8">
<input type="email" class="form-control" id="inputEmail" placeholder="you@example.com" name="email" required>
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="telephone">Mobile</label>
<div class="col-xs-8">
<input type="tel" class="form-control" id="Mobile" placeholder="Phone number" name="telephone">
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="exampleTextarea" name="comments"></label>
<textarea class="form-control" id="exampleTextarea" rows="6" name="comments" placeholder="What is your enquiry?" required></textarea>
<div class="form-group">
<div class="col-xs-12">
<input type="submit" class="btn btn-primary" value="Submit">
</div>
</div>
</form>
</div>
</div>
</div>
<p></p>
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['email'])) {
//Email information
$admin_email = "#######@gmail.com";
$first_name = $_REQUEST['first_name'];
$last_name = $_REQUEST['last_name'];
$email = $_REQUEST['email'];
$telephone = $_REQUEST['telephone'];
$comments = $_REQUEST['comments'];
//send email
mail($admin_email, "$first_name", $last_name, "$telephone", "$comments", "From:" . $email);
//Email response
echo "Thank you for contacting us!";
}
//if "email" variable is not filled out, display the form
else {
?>
<?php
}
?>
</body>
</html>
答案 0 :(得分:1)
更改此
<form name="enquiryform" method="post" action="">
<h2>Contact us!</h2>
<form class="form-horizontal">
到
<form class="form-horizontal" name="enquiryform" method="post" action="#">
<h2>Contact us!</h2>