Php 如何从<;获取静态值;选择>;html标签?

Php 如何从<;获取静态值;选择>;html标签?,php,html,Php,Html,我正在用php制作一份包含文本、文件、选择和文本区域等多个字段的就业表格。当有人提交表单时,我收到电子邮件中的文本和文本区域字段,但没有选择的值和文件(附件) 我的php代码是: if(trim($_POST['FindElance']) || ($_POST['FindGoogle']) || ($_POST['Findsarch']) || ($_POST['FindAdvertisement']) || ($_POST['FindOther']) === '') { $Fwhere

我正在用php制作一份包含文本、文件、选择和文本区域等多个字段的就业表格。当有人提交表单时,我收到电子邮件中的文本和文本区域字段,但没有选择的值和文件(附件)

我的php代码是:

if(trim($_POST['FindElance']) || ($_POST['FindGoogle']) || ($_POST['Findsarch']) || ($_POST['FindAdvertisement']) || ($_POST['FindOther']) === '') {
    $FwhereError = 'Please tell where you find us.';
    $FwhereError = true;
} else {
    $Fwhere = trim($_POST['Fwhere']);
}
以下是电子邮件正文变量,它将向我的电子邮件发送值:

$body = " 
Where you find us : $Fwhere
";
这是HTML的代码,我试图在这里得到验证等:

<div class="clear">How did you find us? : <span class="error">*</span><br></div>

<label class="overyalk" for="areaofinterest"></label>

<select id="wherefrom" class="era-select" name="howufindus" onclick="showhere()">
    <option value="FindElance">Elance</option>
    <option value="FindGoogle">Google</option>
    <option value="Findsarch">Search&nbsp;engin</option>
    <option value="FindAdvertisement">Advertisment</option>
    <option value="FindOther">Other</option>
</select>

</div>
你是怎么找到我们的*
埃兰斯 谷歌 搜索引擎 广告 其他
我被它困住了,不知道该怎么做。这是我工作的在线表格

你也可以下载我正在创建的文件。这是一个文件,它是一个主题内的Wordpress页面


您的问题不够清楚:(

无论如何,试试这个

$body = "Where you find us : ". $Fwhere;

您的HTML代码中没有
FindElance
FindGoogle
Fwhere

您在表格中选择的名称为“howufindus

因此,您应该在
$\u POST
中使用它,如下所示:

if(!$_POST['howufindus']) {
    $FwhereError = 'Please tell where you find us.';
    $FwhereError = true;
} else {
    $Fwhere = trim($_POST['howufindus']);
}
对于附件,您必须使用
$\u文件


希望这有帮助

在本地系统上尝试此代码作为起点

<?php
if($_POST) {
echo "<pre>";
print_r($_POST);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
    <form name="test" method="post" action="" name="testform">
        <select name="testselect">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
        </select>
        <input type="file" name="testfiel" />
        <input type="submit" value="submit" />
    </form>    
</body>
</html>

无标题文件
1.
2.
3.

这将向您显示提交表单后获得的参数,并且不添加上载的文件作为扩展名,您需要使用$\u file方法检查它。

这是您想要的吗

if(isset($_POST['Fwhere'])) {

$Fwhere = $_POST['Fwhere'];

}
<select id="wherefrom" class="era-select" name="howufindus" onclick="showhere()">
    <option value="FindElance">Elance</option>
    <option value="FindGoogle">Google</option>
    <option value="Findsarch">Search&nbsp;engin</option>
    <option value="FindAdvertisement">Advertisment</option>
    <option value="FindOther">Other</option>
</select>

$_POST['FindElance'], $_POST['FindElance'], $_POST['Findsarch']...

根据您的html选择框,您将无法通过以下方式获得所选值:

$_POST['howufindus'];
您的php将更改为:


干杯

这些FindElance、FindGoogle等在哪里?Fwhere在哪里?实际上,会有两个“名称”告诉php获取值。一个是选择标记名和其他选项名。我已经编写了php代码,但不知道如何使用html来获取值。我正在尝试从选择标记获取值,并希望在电子邮件中获取它。例如示例如果有人从选项标签中选择了“Odesk”,则提交时应该是电子邮件中的。请提供任何帮助。这是我在打开html之前打印网站标签的表单。另外,
if($\u POST)
也不是查看表单是否已发布的好方法…请提供任何帮助?这是我正在我的网站上处理的表单。Joran,感谢您的评论,尽管这只是一个快速代码,以便Waseem可以开始…你好,SKV。我已更新了我的问题,并添加了一个文件链接,以便您可以下载此文件。下载链接是的,我想要用户只选择一个值。然后它将存储在一个变量中,然后我将在我的电子邮件正文中使用该变量,我可以获得值。请您也用html向我显示一下好吗?我还尝试了@Ahamed this one
if(isset($_POST['howufindus']){$FwhereError='请告诉我们在哪里。;$FwhereError=true;}其他{$FindDelance=$\u POST['FindDelance'];$FindGoogle=$\u POST['FindGoogle'];$FindSearch=$\u POST['FindSearch'];$FindAdvertisient=$\u POST['FindDelance'];$FindTother=$\u POST['FindGoogle'];
$_POST['howufindus'];
if(trim($_POST['howufindus'])) === '') {
    $FwhereError = 'Please tell where you find us.';
    $FwhereError = true;
} else {
    $Fwhere = trim($_POST['Fwhere']);
}