0

次のコードがあります。

<html>
<head>
<title>Write to a text file</title>
</head>
<body>
Add your text
<form action="" method='post'>
<input name='textblock'></input>
<input name='otherblock'></input>
<input type='submit' value='Add text'>

</form>

<?php

// Open the text file
$f = fopen("texties.txt", "a");

// Write text
fwrite($f, $_POST["textblock"] . $_POST["otherblock"] . "\r\n");

// Close the text file
fclose($f);

$filecontents = file_get_contents("texties.txt");
print nl2br($filecontents);
?>

</body> 
</html>

これにより、ユーザーがテキスト ボックスに入力したものは何でも生成されます。たとえば、「blue」や「buffalo」は次のようになります。

ブルーバッファロー

どうすれば読めるようになりますか

ブルーバッファロー

ありがとうございました!

4

2 に答える 2

0

これを見ると自分を蹴るでしょうが、簡単です:

<html>
<head>
<title>Write to a text file</title>
</head>
<body>
Add your text
<form action="" method='post'>
<input name='textblock'></input>
<input name='otherblock'></input>
<input type='submit' value='Add text'>

</form>

<?php

// Open the text file
$f = fopen("texties.txt", "a");

// Write text
fwrite($f, $_POST["textblock"] . " " . $_POST["otherblock"] . "\r\n");

// Close the text file
fclose($f);

$filecontents = file_get_contents("texties.txt");
print nl2br($filecontents);
?>

</body> 
</html>
于 2013-10-03T01:26:00.727 に答える