未通过PHP电子邮件捕获表单的Select Box Selected选项
我在我的网站中使用一个表单,所有字段都被捕获并通过PHP作为电子邮件发送,但选择框选项没有被捕获或发送 我的表格代码是:未通过PHP电子邮件捕获表单的Select Box Selected选项,php,html,forms,Php,Html,Forms,我在我的网站中使用一个表单,所有字段都被捕获并通过PHP作为电子邮件发送,但选择框选项没有被捕获或发送 我的表格代码是: <form id="contact" class="contact-form" name="contact" method="post" novalidate> <fieldset> <div class="form-input-group" id="form-container"> <input id="n
<form id="contact" class="contact-form" name="contact" method="post" novalidate>
<fieldset>
<div class="form-input-group" id="form-container">
<input id="name" type="text" name="name" size="30" placeholder="Name">
<i class="fa fa-male" id="form-icon"></i>
</div>
<div class="form-input-group text-container test box" id="form-container">
<i class="fa fa-envelope" id="form-icon"></i>
<select id="selector" class="selector" name="selector">
<option value="hide" selected>Select One</option>
<option value="1">One</option>
<option value="2">Two</option>
</select>
</div>
<input type="submit" class="form-btn form-btn-fill" id="contact-submit" name="submit" value="Submit">
</fieldset>
</form>
我的PHP是:
<?php
$to = "hello@website.com";
$from = $_REQUEST['email'];
$subject = "Website Contact Form Submission";
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$selector = $_REQUEST['selector'];
$body = "
<html>
<head>
<meta charset=\"utf-8\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />
</head>
<body style=\"margin: 0; padding: 0;\">
<!-- FORM CONTENT SECTION -->
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
<tr>
<td bgcolor=\"#ffffff\" align=\"center\" style=\"padding: 15px 15px 15px 15px;\" class=\"section-padding\">
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"500\" class=\"responsive-table\">
<tr>
<td align=\"left\" style=\"padding: 12px 12px 5px 12px; font-size: 13px; line-height: 18px; font-family: Helvetica, Arial, sans-serif; color: #aaaaaa; border-top: 1px solid #3eb489;\">Name</td>
</tr>
<tr>
<td align=\"left\" style=\"font-family: Arial, sans-serif; color: #333333; font-size: 16px; padding: 0 12px 12px 12px;\">$name</td>
<tr>
<td align=\"left\" style=\"padding: 12px 12px 5px 12px; font-size: 13px; line-height: 18px; font-family: Helvetica, Arial, sans-serif; color: #aaaaaa; border-top: 1px solid #eaeaea;\">Selector</td>
</tr>
<tr>
<td align=\"left\" style=\"font-family: Arial, sans-serif; color: #333333; font-size: 16px; padding: 0 12px 12px 12px; border-bottom: 1px solid #3eb489; line-height: 24px;\">$selector</td>
</tr>
</table>
</body>
</html>
";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "Return-Path: ".$name." <".$email.">\r\n";
$headers .= "From: ".$name." <".$email.">\r\n";
$send = mail($to, $subject, $body, $headers);
?>
非常感谢 您可以在html中进行更改
<select id="selector" class="selector" name="selector">
<option value="hide" >Select One</option>
<option value="1">One</option>
<option value="2">Two</option>
</select>
我用$\u POST替换了$\u请求,这似乎起到了作用。为什么删除所选选项可以解决这个问题?这只是设置了默认选项,一旦用户选择其他选项,它就没有任何效果。同意,对发布的表单变量没有任何影响var\u dump$\u请求显示了什么?我尝试了$\u POST,但仍然没有任何结果:@Barmar我将如何使用我的PHP尝试您的方法?我是否按原样添加?$\u POST或$\u REQUEST的var\u dump应该显示从表单/提交到脚本中的所有内容。这只是一个调试语句,它显示变量的内容。