我的php表单已经停止通过新的查询发送到我的电子邮件,因为我更新它以提交给自己。
我已尝试使用我的网站主机和Gmail地址的电子邮件地址。任何建议将不胜感激。
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div class="col-lg-12">
<h2>Contact us!</h2>
<form class="form-horizontal" name="enquiryform" method="post" action="">
<div class="form-group-lg">
<label class="control-label col-xs-4" for="name">Name *</label>
<div class="col-xs-8">
<input type="text" class="form-control" id="name" placeholder="First name" name="name" required>
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="surname">Surname</label>
<div class="col-xs-8">
<input type="text" class="form-control" id="surname" placeholder="Last name" name="surname">
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="email">Email *</label>
<div class="col-xs-8">
<input type="email" class="form-control" id="email" placeholder="you@example.com" name="email" required>
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="mobile">Mobile</label>
<div class="col-xs-8">
<input type="tel" class="form-control" id="mobile" placeholder="Phone number" name="mobile">
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="message" name="message">Enquiry:</label>
<textarea class="form-control" id="message" rows="6" name="message" placeholder="Your message." required></textarea>
<div class="form-group">
<div class="col-xs-12">
<input type="submit" class="btn btn-primary" value="Submit">
</div>
</div>
</div>
</form>
</div>
</div>
<p></p>
<?php
$name = $_POST['name'];
$surname = $_POST['surname'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$message = $_POST['message'];
$formcontent="From: $email \n $name \n $surname \n $mobile \n Message: $message";
$recipient = "me@host.com";
$subject = "Enquiry";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
?>
</body>
答案 0 :(得分:0)
php电子邮件发送功能的语法是:
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
mail($admin_email, "$first_name", $last_name, "$telephone", "$comments", "From:" . $email);
但在您的情况下,您的参数与所需参数不匹配。 请按照语法重试。
答案 1 :(得分:0)
你使用了邮件功能中传递的额外参数..我改变了你的一些代码看看。
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<?php
$action=$_REQUEST['action'];
if ($action=="")
{
?>
<div class="col-lg-12">
<h2>Contact us!</h2>
<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="name" required>
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="surname">Surname</label>
<div class="col-xs-8">
<input type="text" class="form-control" id="surname" placeholder="Last name" name="surname">
</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="mobile">
</div>
</div>
<div class="form-group-lg">
<label class="control-label col-xs-4" for="exampleTextarea" name="message">Enquiry:</label>
<textarea class="form-control" id="exampleTextarea" rows="6" name="message" placeholder="Your message." required></textarea>
<div class="form-group">
<div class="col-xs-12">
<input type="submit" class="btn btn-primary" value="Submit">
</div>
</div>
</div>
</form>
</div>
</div>
<p></p>
<?php
}
else
{
$name = $_REQUEST['name'];
$surname = $_REQUEST['surname'];
$email = $_REQUEST['email'];
$mobile = $_REQUEST['mobile'];
$message = $_REQUEST['message'];
$formcontent="From: $email \n $name \n $surname \n $mobile \n Message: $message";
$recipient = "me@host.com";
$subject = "Enquiry";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
}
?>
</body>
</html>
如果此处有任何查询评论......