我有代碼當用戶輸入一個句子並按下添加文本按鈕 然後文本被髮送到文件。用戶輸入的間隔條目寫入文件的形式
下面是代碼
<html>
<head>
<title>Write to a text file</title>
</head>
<body>
Put Cataline/page.txt furni info,
<form action="" method='post'>
<input name='textblock'></input>
<input type='submit' value='Add text'>
</form>
<?php
// Open the text file
$f = fopen("textfile.txt", "a");
// Write text
fwrite($f, $_POST["textblock"]);
// Close the text file
fclose($f);
// Open file for reading, and read the line
$f = fopen("textfile.txt", "r");
// Read text
echo fgets($f);
fclose($f);
?>
</body>
</html>
它工作正常。有一個問題。
我會用一個例子來展示它。
用戶1:哦哦,我可以在這裏上傳我的furnidata確定生病做進入furnidata牛逼 (User 1的furnidata(他想要添加的文本)被髮送到文件。)(它的工作原理)
現在用戶2走來
用戶2:輪到我加furni數據(不一樣的user1和它上傳到文件和工作正常
但
這是與c頌看起來像
user1furnidatatatatblahblahblahendofdatauser2furnidatablahblahblahendofdata
這是我希望它看起來像
user1furnidatatatatblahblahblahendofdata
user2furnidatablahblahblahendofdata
任何人都可以建議我實現這一目標?
謝謝你的傳奇我會代表你,如果我可以,但我不能因爲我是一個新用戶 –
沒有問題的享受的事實:) – Tredged
你能否代我的帖子呢?你有足夠的代表我upvoted也。謝謝。 – Tredged