如何从<;中选择要运行的代码;选择>;html标记PHP

如何从<;中选择要运行的代码;选择>;html标记PHP,php,html,Php,Html,我有一个选择下拉列表: <form action="member.php" method="POST" enctype="multipart/form-data"> <table width="80%"> <tr> <td class="borderblack">Select Phone Type: <select name="phone_type">

我有一个选择下拉列表:

    <form action="member.php" method="POST" enctype="multipart/form-data">
<table width="80%">
    <tr>
        <td class="borderblack">Select Phone Type:
            <select name="phone_type">
                    <option value="escene" name="escene">Escene</option>
                    <option value="grandstream" name="grandstream">Grandstream</option>
            </select>

            <input type="submit" name="phone_typesub">
        </td>


        <td class="borderblack">
            <label for="file">Upload XML:</label>
            <input type="file" name="file" id="file">
            <input type="submit" name="submit" >
        </td>   
</form>

选择电话类型:
艾斯肯
潮流网络
上载XML:

根据选择的下拉选项,我希望运行包含在不同文件中的特定代码块。我想知道是否有人能给我建议。(php文件中有2个代码块)

类似于
member.php中的内容:

if($_POST['phone_type']=='escene'){
    import 'escene_handler.php';       // run this if they selected 'escene'
}else if($_POST['phone_type']=='grandstream'){
    import 'grandstream_handler.php';  // run this if they selected 'grandstream'
}

提交表单时将调用该函数。

我认为AJax是解决此问题的最佳解决方案。

您可以使用以下简单语句:

if (!empty($_POST)) {
    switch ($_POST['phone_type']) {
        case 'escene':
            // run your code when 'escene' is selected
            break;
        case 'grandstream':
            // run your code when 'grandstream' is selected
            break;
        default:
            // run default code, when non of the above is selected, or ignore
    }
}
`

这可能会起作用。

两个代码块都在同一个php页面中吗?您希望在他们提交表单或单击某个选项时运行此代码吗?(POST或AJAX)您尝试了什么?在你的问题中,我看不到有人试图解决这个问题。我们不是来为你写代码的。
<?php if(isset($_POST['YourDropDownName']) && $_POST['YourDropDownName'] == "Option1Value")
{
    //do stuff here...
}
else if(isset($_POST['YourDropDownName']) && $_POST['YourDropDownName'] == "Option2Value")
{
    //do other stuff here...
}?>`