php下拉列表和其他表单一起提交

php下拉列表和其他表单一起提交,php,html,drop-down-menu,Php,Html,Drop Down Menu,嘿,这个问题看起来很容易解决,但我找不到任何解决方案,我的下拉列表没有保存 <?php // the relative path to the file $fname = "Erros1.txt"; $fname2 = "Comentarios.txt"; // read in the file if present if(file_exists($fname)) $txt = file_get_contents($fname); if(file_exi

嘿,这个问题看起来很容易解决,但我找不到任何解决方案,我的下拉列表没有保存

<?php
   // the relative path to the file
   $fname = "Erros1.txt";
   $fname2 = "Comentarios.txt";
   // read in the file if present
   if(file_exists($fname)) $txt = file_get_contents($fname);
   if(file_exists($fname2)) $Comentarios = file_get_contents($fname2);    

   // if the user pushes the submit button
   if(isset($_POST["Comentarios"])){
       $Comentarios = $_POST["Comentarios"];   // get the entered content    
       file_put_contents($fname2,$Comentarios);    // write the content to the file
   }

   if (isset($_POST["dropdown"])) {
       // cast to integer to avoid malicious values
       $dropdown = (int)$_POST["dropdown"];
   }

?>

<form method="post" action="#">
<textarea name = "txt" cols = "120" rows = "20">
<?php echo $txt; ?>
</textarea>

<textarea name = "Comentarios" cols = "120" rows = "10">
<?php echo $Comentarios; ?>
</textarea>

// here is the dropdown
<select name="dropdown";>   
<?php
    for ($x=1; $x<=4; $x++) {
        echo '<option value="' . $x . '">' . $x . '</option>' . PHP_EOL;   
    }
    echo $_POST['dropdown']
?>
</select>

<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>

//这是下拉列表

只有我的Comentarios框正在保存,可能我需要更改提交或创建另一个表单

应该保存的
下拉列表
保存代码在哪里?上面的代码没有通过设计保存下拉列表的值如果“保存”是指写入文件–好的,您只对textarea值执行此操作,而不是对从select中获取的数据执行此操作…因此我也需要将其保存到文件中?如果您希望将其保存到文件中,请执行。但是,正如您的代码目前所处的状态,您所要做的就是将下拉值转换为整数,然后对其不做任何处理。你为什么希望它被保存?我如何保存它们?