Skip to content

Instantly share code, notes, and snippets.

@masakielastic
Created July 27, 2015 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masakielastic/88c1be23d5e8835fbe29 to your computer and use it in GitHub Desktop.
Save masakielastic/88c1be23d5e8835fbe29 to your computer and use it in GitHub Desktop.
textarea の練習。投稿内容をテキストファイルとして保存。
<?php
if (isset($_POST['message'])) {
file_put_contents('db.txt', $_POST['message']);
$text = $_POST['message'];
} else {
$text = file_get_contents('db.txt');
}
$text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
?>
<form action="/test/index.php" method="POST">
<p>
<input type="submit" value="保存する" />
</p>
<p>
<input type="textarea" style="padding: 5px; margin : 10px; text-align:left; width: 300px; height: 150px;" name="message" value="<?= $text ?>" />
</p>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment