dougan4663 2013-10-08 13:06 采纳率: 0%
浏览 8

用另一种形式的php下拉并提交

Hey this problem may look really easy to solve but i can't find any solution, my dropdown isn't saving

<?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>

Only my Comentarios Box is saving, maybe i need to change the submit or create another form

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用
    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教