teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

2017/05/24 02:11

投稿

ogawat
ogawat

スコア12

title CHANGED
@@ -1,1 +1,1 @@
1
- MYSQL
1
+ phpに関するしつもん
body CHANGED
@@ -1,48 +1,1 @@
1
- <html>
2
- <head>
3
- <meta http-equiv="content-type" content="text/html;charset=UTF8;" />
4
- <table border="1">
5
- <form action="for3.php" method="POST">
6
- <tr><th>タイトル<td><input type="text" name="text" size="50"></td></tr>
7
- <tr><th>本文<td><textarea name="subject" cols="52" rows="8"></textarea>
8
- <tr><td><input type="submit" value="保存 する" /></td><tr>
9
- </table>
10
- </form>
11
- <?php
12
- $text = htmlspecialchars($_REQUEST['text']);
13
- var_dump($_REQUEST);
14
- ?>
15
- <?php
16
- $subject = (isset($_POST['subject']))&&(is_string($_POST['subject'])) ? trim($_POST['subject']) : '';
17
- $text = (isset($_POST['text']))&&(is_string($_POST['text'])) ? trim($_POST['text']) : '';
18
- if (($subject !== "")&&($text !== "")) {
19
- $subject = htmlspecialchars($subject);
20
- $text = str_replace(array("\r", "\n"), "", nl2br($text));
21
- $fp = fopen('test1.txt', 'a');
22
- flock($fp, LOCK_EX);
23
- fwrite($fp, implode('<>', array($text, $subject, date('Y-m-d h:i:s'))) . PHP_EOL);
24
- flock($fp, LOCK_UN);
25
- fclose($fp);
26
- } else {
27
- if ($_POST) { $errmsg = "入力が不足しています"; }
28
- }
29
-
30
- if (isset($errmsg)) { printf('<strong style="color:#e01;">%s</strong><br />', $errmsg); }
31
- ?>
32
- <strong style="color:#e01;">タイトルと本文を入力してください</strong><br />
33
- <?php
34
- if (file_exists('test1.txt')) {
1
+ プルダウンはどのようにしたら作れますか?詳しく書かれているものありましたらお願いします
35
- $fp = fopen('test1.txt', 'r');
36
- while ($line = fgets($fp)) {
37
- list($text, $subject, $date) = explode('<>', $line);
38
- printf('<div class="box"><strong style="float:left;">%s</strong><small
39
- style="float:right;">%s</small><p style="clear:both;">%s</p></div>', $text,
40
- $date, $subject);
41
-
42
- }
43
- }
44
- ?>
45
- </div>
46
- </body>
47
- </html>
48
- phpで以前作成したものをXAMPP MYSQL DBに保存形式をファイルからDB形式に変更してみて追加したいですがどうしたらいいかわからないため参考になるサイト、参考書などないでしょうか?