使用php将html表单转换为txt

使用php将html表单转换为txt,php,html,easyphp,Php,Html,Easyphp,我知道为什么,但这对我不起作用 这在index.html中 <form action="myprocessingscript.php" method="POST"> <input name="field1" type="text" /> <input name="field2" type="text" /> <input type="submit" name="submit" value="Save Data"> </

我知道为什么,但这对我不起作用

这在index.html中

<form action="myprocessingscript.php" method="POST">
    <input name="field1" type="text" />
    <input name="field2" type="text" />
    <input type="submit" name="submit" value="Save Data">
</form>

在myprocessingscript.php中

<?php
if(isset($_POST['field1']) && isset($_POST['field2'])) {
    $data = $_POST['field1'] . '-' . $_POST['field2'] ."\n";
    $ret = file_put_contents('log.txt', $data, FILE_APPEND | LOCK_EX);
    if($ret === false) {
        die('There was an error writing this file');
    }
    else {
        echo "$ret bytes written to file";
    }
}
else {
   die('no post data to process');
}
?>

log.txt存在


有人有主意吗

检查文件路径和权限。如果您在unix/linux计算机上,请查看permissionsTry removing LOCK\u Ex是否有任何错误?空白页。使用mac。