PHP下拉列表,如何获取所选文本?

时间:2018-12-05 12:43:02

标签: php dropdown

我有以下下拉框:

loop
{
    if /SomewhereInAndroidDevice/cmd.txt:
        read /SomewhereInAndroidDevice/cmd.txt;
        if(cmd == SEND_DATA)
            call required method to send data to another APP;
        deleate /SomewhereInAndroidDevice/cmd.txt;
}

现在我想将文本发送到发送电子邮件的函数中 (该电子邮件有效,我已经在其他领域进行了测试。

$types = array('Article','Preface','Review');
$type = isset($_POST['type']) && in_array($_POST['type'],$types)?$_POST['type']:'Article';

echo '<select name="type">';
foreach($types as $option) {
     echo '<option value="'.$option.'"'.(strcmp($option,$type)==0?' selected="selected"':'').'>'.$option.'</option>';
}
echo '</select>';

但是,类型和类型中的结果为空,选项有些混乱,我无法获得下拉菜单的确切功能

1 个答案:

答案 0 :(得分:0)

谢谢。问题是我混合了变量的顺序,所以我得到的变量不是正确的变量(混合了$ controlnumber和$ version的顺序)。

function mail_control ($email, $gender, $firstname, $lastname, $controlnumber, $version)

mail_control ( $_GET['email'],
                         $_GET['gender'],
                         $_GET['firstname'],
                         $_GET['lastname'],
                         $_GET['version'],
                         $_GET['controlnumber']);