Select 元素未发布
Select element not posting
我有点挣扎 - 谁能解释为什么 select 元素没有为我发帖?其余的表单字段都很好地发布到电子邮件中,只是 select 是空白的。
非常感谢您的帮助!
<form action="/mail.php" method="POST">
<div id=”mainselection”>
<select name="type">
<option value="one">One</option>
<option value="two">Two</option>
<option value="three">Three</option>
<option value="four">Four</option>
<option value="five">Five</option>
<option value="six">Six</option>
<option value="seven">Seven</option>
</select>
</div>
<p>Full Name</p>
<input type="text" class="form-inputs" name="name">
<p>Email Address</p>
<input type="text" class="form-inputs" name="email">
<p>Mobile Number</p>
<input type="text" class="form-inputs" name="phone">
<p>Postcode</p>
<input type="text" class="form-inputs" name="postcode">
<input type="submit" class="send" value=" Contact Us ">
</form>
<?php
$accidenttype = $_POST['type'];
$name = $_POST['name'];
$email = $_POST['email'];
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))
{
die("E-mail address not valid<br><br>
You are now being redirected back");
}
$phone = $_POST['phone'];
$postcode = $_POST['postcode'];
$formcontent="Type: $type \n From: $name \n Email: $email \n Phone: $phone \n postcode: $postcode";
$recipient = "email@address.com";
$subject = "Email Subject";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
{print "Thank you message"; }
?>
在您的 $formcontent
变量中,您指定 $type
作为要在电子邮件中打印的变量。但是,您在上面将该变量命名为 $accidenttype
。变量 $type
为空,这就是您得到空结果的原因。
我有点挣扎 - 谁能解释为什么 select 元素没有为我发帖?其余的表单字段都很好地发布到电子邮件中,只是 select 是空白的。 非常感谢您的帮助!
<form action="/mail.php" method="POST">
<div id=”mainselection”>
<select name="type">
<option value="one">One</option>
<option value="two">Two</option>
<option value="three">Three</option>
<option value="four">Four</option>
<option value="five">Five</option>
<option value="six">Six</option>
<option value="seven">Seven</option>
</select>
</div>
<p>Full Name</p>
<input type="text" class="form-inputs" name="name">
<p>Email Address</p>
<input type="text" class="form-inputs" name="email">
<p>Mobile Number</p>
<input type="text" class="form-inputs" name="phone">
<p>Postcode</p>
<input type="text" class="form-inputs" name="postcode">
<input type="submit" class="send" value=" Contact Us ">
</form>
<?php
$accidenttype = $_POST['type'];
$name = $_POST['name'];
$email = $_POST['email'];
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))
{
die("E-mail address not valid<br><br>
You are now being redirected back");
}
$phone = $_POST['phone'];
$postcode = $_POST['postcode'];
$formcontent="Type: $type \n From: $name \n Email: $email \n Phone: $phone \n postcode: $postcode";
$recipient = "email@address.com";
$subject = "Email Subject";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
{print "Thank you message"; }
?>
在您的 $formcontent
变量中,您指定 $type
作为要在电子邮件中打印的变量。但是,您在上面将该变量命名为 $accidenttype
。变量 $type
为空,这就是您得到空结果的原因。