2014-07-24 98 views
0

我正在嘗試將PHP腳本寫入純文本文件。我以前做過這件事,它工作得很好。但由於某種原因,這次不起作用。
這裏是我使用的HTML:PHP 5.3將內容寫入純文本

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <meta charset="utf-8" /> 
     <link rel="stylesheet" type="text/css" href="/css/feedback.css" > 
     <title>Questions, Comments, Suggestions</title> 
    </head> 
    <body> 
     <p class="title">Questions, comments, and suggestions here!</p> 
      <form method="post" name="userFeedback" action="/submit.php"> 
      <textarea id="comments" placeholder="Leave a comment or review here..."></textarea> 
      <textarea id="name" placeholder="Your name here"></textarea> 
      <textarea id="contact" placeholder="Put any means of contact you want to here (optional)"></textarea> 
      <br> 
      <input class="enter" type="submit" value="Enter"> 
     </form> 
    </body> 
</html> 

所有我想這個做的是打印出來無論是進入到平原,PHP 5.3 .txt文件。這裏是代碼:

$data = ($_POST["comments"] ." || ". $_POST["name"] ." || ". $_POST["contact"]); 
    $data = strip_tags($data); 

    $file = "feedback.txt"; 
    $f = fopen($file, "a+"); 

    fwrite($f, $data . "\n" . "\n"); 

    fclose($f); 

    header ('Location: index.html'); 

請記住,我使用5.3。我確信這裏有一個簡單的錯誤。有人可以幫我弄這個嗎?先謝謝你!

回答

0

我們明白了!原來,PHP $ _POST方法尋找「name」屬性而不是「id」。