嘿,这个问题看起来很容易解决,但我找不到任何解决方案,我的下拉菜单没有保存
<?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>
只有我的评论框正在保存,也许我需要更改提交或创建另一个表单