如何将文本框内容提交生成文件
用php制作了个页面,想在文本框输入数据,点提交后将数据保存到文件,可是点提交后显示500错误,不知道错误在哪,那位帮看看web.php内容如下:
<!DOCTYPE HTML>
<html>
<body>
<form action="/re_config.php" method="post">
<div align="center">服务器:<input type="text" name="ftp_server "><br>
服务器端口:<input type="text" name="ftp_port"><br><br>
<input type="submit">
</div>
</form>
</body>
</html>
re_config.php内容如下:
<html>
<body>
<?php
$myfile = fopen("/sig.s", "w") or die("Unable to open file!");
$txt = $_POST["ftp_port"]\n;
fwrite($myfile, $txt);
fclose($myfile);
?>
</body>
</html> 本帖最后由 reb00t 于 2014-10-07 10:09 编辑
$txt = $_POST["ftp_port"]\n;
这行的问题。
修改如下:
<?php
$dir = dirname(__FILE__ );
$myfile = fopen("$dir/sig.s", "a+") or die("Unable to open file!");
$txt = $_POST['ftp_port']."\r\n";
fwrite($myfile, $txt);
fclose($myfile);
?>windows机器下换行是\r\n, linux下只需要\n 楼主在写自动化运维后台吗?:mrgreen:
页:
[1]