質問編集履歴
2
誤字の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
<head>
|
36
36
|
|
37
|
-
<title>
|
37
|
+
<title>keijiban.php</title>
|
38
38
|
|
39
39
|
</head>
|
40
40
|
|
@@ -186,7 +186,7 @@
|
|
186
186
|
|
187
187
|
?>
|
188
188
|
|
189
|
-
<form action="
|
189
|
+
<form action="keijiban.php" method="post">
|
190
190
|
|
191
191
|
<br><br>
|
192
192
|
|
1
追記解決したので、編集しましたありがとうございました!指摘通り順番を入れ替えてみたのですがまだ解決しません…
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
どのようにしたらいいかアドバイスをお願いしたいです。
|
24
24
|
|
25
|
-
|
25
|
+
>>解決しました編集済み
|
26
26
|
|
27
27
|
|
28
28
|
|
@@ -30,19 +30,165 @@
|
|
30
30
|
|
31
31
|
```php
|
32
32
|
|
33
|
-
|
34
|
-
|
35
33
|
<html>
|
36
34
|
|
37
35
|
<head>
|
38
36
|
|
39
|
-
<title>
|
37
|
+
<title>mission_2-4.php</title>
|
40
38
|
|
41
39
|
</head>
|
42
40
|
|
43
41
|
<body>
|
44
42
|
|
43
|
+
|
44
|
+
|
45
|
+
<?php
|
46
|
+
|
47
|
+
$filename="keijiban.text";
|
48
|
+
|
49
|
+
$name=$_POST['name'];
|
50
|
+
|
51
|
+
$comment=$_POST['comment'];
|
52
|
+
|
53
|
+
$postedat=date("Y/m/d H:i:s");
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
//新規追加
|
60
|
+
|
61
|
+
if(isset($_POST['name'])&&($_POST['comment'])&&!($_POST['edit'])){
|
62
|
+
|
63
|
+
$lines=file($filename);
|
64
|
+
|
65
|
+
foreach($lines as $line){
|
66
|
+
|
67
|
+
$data=explode("<>",$line);
|
68
|
+
|
69
|
+
$num=0;
|
70
|
+
|
71
|
+
if($num<$data[0]){
|
72
|
+
|
73
|
+
$num=$data[0];
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
$num++;
|
80
|
+
|
81
|
+
$fp=fopen($filename,'a');
|
82
|
+
|
83
|
+
fwrite($fp,$num."<>".$name."<>".$comment."<>".$postedat."<br>\n");
|
84
|
+
|
85
|
+
fclose($fp);
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
//削除
|
92
|
+
|
93
|
+
if (isset($_POST['delete'])){
|
94
|
+
|
95
|
+
$delete=$_POST['delete'];
|
96
|
+
|
97
|
+
$lines=file($filename);
|
98
|
+
|
99
|
+
$fp=fopen($filename,'w');
|
100
|
+
|
101
|
+
foreach($lines as $line){
|
102
|
+
|
103
|
+
$data=explode("<>",$line);
|
104
|
+
|
105
|
+
if($data[0]!=$delete){
|
106
|
+
|
107
|
+
fwrite($fp,$line);
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
fclose($fp);
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
//編集
|
120
|
+
|
121
|
+
$edit_num=$_POST['edit_num'];
|
122
|
+
|
123
|
+
$lines=file($filename);
|
124
|
+
|
125
|
+
foreach($lines as $line){
|
126
|
+
|
127
|
+
$data=explode('<>', $line[0]);
|
128
|
+
|
129
|
+
if($edit_num==$editdata[0]){
|
130
|
+
|
131
|
+
$editdata0=$editdata[0];
|
132
|
+
|
133
|
+
$editdata1=$editdata[1];
|
134
|
+
|
135
|
+
$editdata2=$editdata[2];
|
136
|
+
|
137
|
+
$editdata3=$editdata[3];
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
if(isset($_POST['name'])&&($_POST['comment'])&&($_POST['edit'])){
|
148
|
+
|
149
|
+
$lines=file($filename);
|
150
|
+
|
151
|
+
$fp=fopen($filename,'w');
|
152
|
+
|
153
|
+
$edit=$_POST['edit'];
|
154
|
+
|
155
|
+
foreach($lines as $line){
|
156
|
+
|
157
|
+
$data=explode("<>",$line);
|
158
|
+
|
159
|
+
if($data[0]==$edit){//投稿番号と編集番号が一致したとき上書き
|
160
|
+
|
161
|
+
fwrite($fp,$edit."<>".$name."<>".$comment."<>".$postedat."<br>\n");
|
162
|
+
|
163
|
+
}else{
|
164
|
+
|
165
|
+
fwrite($fp,$line);
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
fclose($fp);
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
//表示
|
176
|
+
|
177
|
+
$lines=file($filename);
|
178
|
+
|
179
|
+
foreach($lines as $line){
|
180
|
+
|
181
|
+
$data=explode("<>",$line);
|
182
|
+
|
183
|
+
echo $data[0].$data[1].$data[2].$data[3]."\n";
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
?>
|
188
|
+
|
45
|
-
<form action="
|
189
|
+
<form action="mission_2-4.php" method="post">
|
190
|
+
|
191
|
+
<br><br>
|
46
192
|
|
47
193
|
投稿:<br>
|
48
194
|
|
@@ -70,138 +216,6 @@
|
|
70
216
|
|
71
217
|
|
72
218
|
|
73
|
-
<?php
|
74
|
-
|
75
|
-
$filename="keijiban.text";
|
76
|
-
|
77
|
-
$name=$_POST['name'];
|
78
|
-
|
79
|
-
$comment=$_POST['comment'];
|
80
|
-
|
81
|
-
$postedat=date("Y/m/d H:i:s");
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
//新規追加
|
88
|
-
|
89
|
-
if(isset($_POST['name'])&&($_POST['comment'])&&!($_POST['edit'])){
|
90
|
-
|
91
|
-
$fp=fopen($filename,'a');
|
92
|
-
|
93
|
-
$num=count(file($filename));
|
94
|
-
|
95
|
-
$num++;
|
96
|
-
|
97
|
-
fwrite($fp,$num."<>".$name."<>".$comment."<>".$postedat."<br>\n");
|
98
|
-
|
99
|
-
fclose($fp);
|
100
|
-
|
101
|
-
}
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
//削除
|
106
|
-
|
107
|
-
if (isset($_POST['delete'])){
|
108
|
-
|
109
|
-
$delete=$_POST['delete'];
|
110
|
-
|
111
|
-
$lines=file($filename);
|
112
|
-
|
113
|
-
$fp=fopen($filename,'w');
|
114
|
-
|
115
|
-
foreach($lines as $line){
|
116
|
-
|
117
|
-
$data=explode("<>",$line);
|
118
|
-
|
119
|
-
if($data[0]!=$delete){
|
120
|
-
|
121
|
-
fwrite($fp,$line);
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
fclose($fp);
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
//編集
|
134
|
-
|
135
|
-
$edit_num=$_POST['edit_num'];
|
136
|
-
|
137
|
-
$lines=file($filename);
|
138
|
-
|
139
|
-
foreach($lines as $line){
|
140
|
-
|
141
|
-
$data=explode('<>', $line[0]);
|
142
|
-
|
143
|
-
if($edit_num==$editdata[0]){
|
144
|
-
|
145
|
-
$editdata0=$editdata[0];
|
146
|
-
|
147
|
-
$editdata1=$editdata[1];
|
148
|
-
|
149
|
-
$editdata2=$editdata[2];
|
150
|
-
|
151
|
-
$editdata3=$editdata[3];
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
}
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
if(isset($_POST['name'])&&($_POST['comment'])&&($_POST['edit'])){
|
162
|
-
|
163
|
-
$lines=file($filename);
|
164
|
-
|
165
|
-
$fp=fopen($filename,'w');
|
166
|
-
|
167
|
-
$edit=$_POST['edit'];
|
168
|
-
|
169
|
-
foreach($lines as $line){
|
170
|
-
|
171
|
-
$data=explode("<>",$line);
|
172
|
-
|
173
|
-
if($data[0]==$edit){//投稿番号と編集番号が一致したとき上書き
|
174
|
-
|
175
|
-
fwrite($fp,$edit."<>".$name."<>".$comment."<>".$postedat."<br>\n");
|
176
|
-
|
177
|
-
}else{
|
178
|
-
|
179
|
-
fwrite($fp,$line);
|
180
|
-
|
181
|
-
}
|
182
|
-
|
183
|
-
fclose($fp);
|
184
|
-
|
185
|
-
}
|
186
|
-
|
187
|
-
}
|
188
|
-
|
189
|
-
//表示
|
190
|
-
|
191
|
-
$lines=file($filename);
|
192
|
-
|
193
|
-
foreach($lines as $line){
|
194
|
-
|
195
|
-
$data=explode("<>",$line);
|
196
|
-
|
197
|
-
echo $data[0].$data[1].$data[2].$data[3]."\n";
|
198
|
-
|
199
|
-
}
|
200
|
-
|
201
|
-
?>
|
202
|
-
|
203
|
-
|
204
|
-
|
205
219
|
</body>
|
206
220
|
|
207
221
|
</html>
|