質問編集履歴

5

誤字を修正

2018/05/09 03:30

投稿

3.a.m.op
3.a.m.op

スコア11

test CHANGED
File without changes
test CHANGED
@@ -64,7 +64,7 @@
64
64
 
65
65
  <button type="button" onclick="history.back()">戻る</button>
66
66
 
67
- <button type="submit" class="btn btn-light border" style="width:150px;">更新</button>
67
+ <button type="submit">更新</button>
68
68
 
69
69
  </form>
70
70
 

4

2018/05/09 03:30

投稿

3.a.m.op
3.a.m.op

スコア11

test CHANGED
File without changes
test CHANGED
@@ -86,7 +86,7 @@
86
86
 
87
87
  ```html
88
88
 
89
- <p class="h4 text-center my-5">更新完了</p>
89
+ <p>更新完了</p>
90
90
 
91
91
  <a href="output.php">更新を確認</a>
92
92
 

3

2018/05/09 03:29

投稿

3.a.m.op
3.a.m.op

スコア11

test CHANGED
File without changes
test CHANGED
@@ -56,7 +56,7 @@
56
56
 
57
57
  <p>入力内容を確認してください</p>
58
58
 
59
- <p><?php echo $message; ?></p>
59
+ <p><?php echo $textarea; ?></p>
60
60
 
61
61
  <form action="save.php" method="post">
62
62
 

2

htmlを追記しました

2018/05/09 03:29

投稿

3.a.m.op
3.a.m.op

スコア11

test CHANGED
File without changes
test CHANGED
@@ -4,17 +4,43 @@
4
4
 
5
5
 
6
6
 
7
- input.phpで入力→confirm.phpで確認表示→save.phpでfile_put_contentsを使って入力内容をtxtファイルに保存→
7
+ input.phpで入力
8
8
 
9
- output.phpでtxtファイルからfile_get_contentsで表示
9
+
10
10
 
11
+ confirm.phpで確認表示
12
+
13
+
14
+
15
+ save.phpで入力内容をtxtファイルに保存
16
+
17
+
18
+
19
+ output.phpでtxtファイルからファイル内容を表示
20
+
21
+
22
+
11
- という流れになってます。
23
+ という流れす。
12
24
 
13
25
 
14
26
 
15
27
  現在、
16
28
 
29
+ input.php
30
+
31
+ ```html
32
+
33
+ <form action="confirm.php" method="post">
34
+
35
+ <textarea name="textarea"></textarea>
36
+
37
+ <button type="submit">確認</button>
38
+
39
+ </form>
40
+
41
+ ```
42
+
17
- confirm.php内では
43
+ confirm.php
18
44
 
19
45
  ```php
20
46
 
@@ -23,6 +49,24 @@
23
49
  $textarea = htmlspecialchars($textarea);
24
50
 
25
51
  $textarea = nl2br($textarea);
52
+
53
+ ```
54
+
55
+ ```html
56
+
57
+ <p>入力内容を確認してください</p>
58
+
59
+ <p><?php echo $message; ?></p>
60
+
61
+ <form action="save.php" method="post">
62
+
63
+ <input type="hidden" name="textarea" value="<?php echo $textarea; ?>">
64
+
65
+ <button type="button" onclick="history.back()">戻る</button>
66
+
67
+ <button type="submit" class="btn btn-light border" style="width:150px;">更新</button>
68
+
69
+ </form>
26
70
 
27
71
  ```
28
72
 
@@ -36,19 +80,37 @@
36
80
 
37
81
  $file = 'file.txt';
38
82
 
39
- file_put_contents ($file, json_encode($textarea));
83
+ file_put_contents ($file, json_encode($textarea));
40
84
 
41
85
  ```
86
+
87
+ ```html
88
+
89
+ <p class="h4 text-center my-5">更新完了</p>
90
+
91
+ <a href="output.php">更新を確認</a>
92
+
93
+ ```
94
+
95
+
42
96
 
43
97
  output.php内では
44
98
 
45
99
  ```php
46
100
 
101
+ $file='file.txt';
102
+
103
+ if (file_exists($file)){
104
+
105
+  $textarea = json_decode(file_get_contents($file));
106
+
47
- echo '<p>'.$textarea.'</p>';
107
+  echo '<p>'.$textarea.'</p>';
108
+
109
+ }
48
110
 
49
111
  ```
50
112
 
51
- ておりますが、
113
+ なっております
52
114
 
53
115
 
54
116
 
@@ -89,3 +151,17 @@
89
151
  にする等変更してみましたがうまくいきません。
90
152
 
91
153
  どうすればタグが表示されず、改行もできるようになるのでしょうか?
154
+
155
+
156
+
157
+ ///////////////////////
158
+
159
+ htmlを追記しました。
160
+
161
+ 初心者なので、以上で必要な情報が揃っているかもわかりませんが、
162
+
163
+ 仕事で必要に迫られ、周りにわかる者もいない中で悩みながら作っております。
164
+
165
+ 業務の都合上、抜粋での記載となり申し訳ありません。
166
+
167
+ どうぞよろしくお願いします。

1

保存するファイルのソースを追記しました

2018/05/09 03:27

投稿

3.a.m.op
3.a.m.op

スコア11

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,14 @@
1
1
  input.phpの<textarea>フォームから、
2
2
 
3
3
  入力された内容を改行まで入力された通りにoutput.phpで表示できるようにしたいです。
4
+
5
+
6
+
7
+ input.phpで入力→confirm.phpで確認表示→save.phpでfile_put_contentsを使って入力内容をtxtファイルに保存→
8
+
9
+ output.phpでtxtファイルからfile_get_contentsで表示
10
+
11
+ という流れになってます。
4
12
 
5
13
 
6
14
 
@@ -15,6 +23,20 @@
15
23
  $textarea = htmlspecialchars($textarea);
16
24
 
17
25
  $textarea = nl2br($textarea);
26
+
27
+ ```
28
+
29
+ save.php内では
30
+
31
+ ```php
32
+
33
+ $textarea = $_POST['textarea'];
34
+
35
+ $textarea = htmlspecialchars($textarea);
36
+
37
+ $file = 'file.txt';
38
+
39
+ file_put_contents ($file, json_encode($textarea));
18
40
 
19
41
  ```
20
42