質問編集履歴

11

修正

2016/12/21 05:47

投稿

cookie.
cookie.

スコア14

test CHANGED
File without changes
test CHANGED
@@ -46,16 +46,6 @@
46
46
 
47
47
  <?php
48
48
 
49
-
50
-
51
- $id = $_POST["id"];
52
-
53
- $name = $_POST["name"];
54
-
55
- $comment = $_POST["comment"];
56
-
57
-
58
-
59
49
  try { if($_SERVER['REQUEST_METHOD'] === 'POST') {
60
50
 
61
51
  //SQLに接続
@@ -86,13 +76,11 @@
86
76
 
87
77
 
88
78
 
89
- header('絶対パス',true,303);
79
+ header('Location:絶対パス',true,303);
90
80
 
91
81
  }
92
82
 
93
83
  else{
94
-
95
- if ($stm->execute()){
96
84
 
97
85
  // データベースから全ての投稿を取り出して、ページに表示
98
86
 
@@ -116,12 +104,6 @@
116
104
 
117
105
  }
118
106
 
119
- } else {
120
-
121
- echo '追加エラーがありました';
122
-
123
- }
124
-
125
107
  }
126
108
 
127
109
  } catch (Exception $e) {

10

セミコロン

2016/12/21 05:47

投稿

cookie.
cookie.

スコア14

test CHANGED
File without changes
test CHANGED
@@ -86,7 +86,7 @@
86
86
 
87
87
 
88
88
 
89
- header('絶対パス',true,303)
89
+ header('絶対パス',true,303);
90
90
 
91
91
  }
92
92
 

9

記述改善

2016/12/21 03:13

投稿

cookie.
cookie.

スコア14

test CHANGED
File without changes
test CHANGED
@@ -86,7 +86,7 @@
86
86
 
87
87
 
88
88
 
89
- header('http://test1013.sub.jp/index.php',true,303)
89
+ header('絶対パス',true,303)
90
90
 
91
91
  }
92
92
 

8

記述改善

2016/12/20 08:26

投稿

cookie.
cookie.

スコア14

test CHANGED
File without changes
test CHANGED
@@ -84,6 +84,10 @@
84
84
 
85
85
  $stm->execute();
86
86
 
87
+
88
+
89
+ header('http://test1013.sub.jp/index.php',true,303)
90
+
87
91
  }
88
92
 
89
93
  else{

7

記述改善

2016/12/20 08:25

投稿

cookie.
cookie.

スコア14

test CHANGED
File without changes
test CHANGED
@@ -110,8 +110,6 @@
110
110
 
111
111
 
112
112
 
113
- ";
114
-
115
113
  }
116
114
 
117
115
  } else {

6

記述改善

2016/12/20 08:21

投稿

cookie.
cookie.

スコア14

test CHANGED
File without changes
test CHANGED
@@ -118,7 +118,7 @@
118
118
 
119
119
  echo '追加エラーがありました';
120
120
 
121
- };
121
+ }
122
122
 
123
123
  }
124
124
 

5

記述改善

2016/12/20 08:20

投稿

cookie.
cookie.

スコア14

test CHANGED
File without changes
test CHANGED
@@ -82,7 +82,7 @@
82
82
 
83
83
  $stm->bindValue(':comment', $comment, PDO::PARAM_STR);
84
84
 
85
- $stm->execute()
85
+ $stm->execute();
86
86
 
87
87
  }
88
88
 

4

記述改善

2016/12/20 08:19

投稿

cookie.
cookie.

スコア14

test CHANGED
File without changes
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  よろしくお願いします。
24
24
 
25
- ,,,PHP
25
+ ```PHP
26
26
 
27
27
  index.php
28
28
 
@@ -138,4 +138,4 @@
138
138
 
139
139
  </body>
140
140
 
141
- ,,,
141
+ ```

3

書式改善

2016/12/20 08:18

投稿

cookie.
cookie.

スコア14

test CHANGED
File without changes
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  よろしくお願いします。
24
24
 
25
- 、、、PHP
25
+ ,,,PHP
26
26
 
27
27
  index.php
28
28
 
@@ -138,4 +138,4 @@
138
138
 
139
139
  </body>
140
140
 
141
- 、、、
141
+ ,,,

2

記述改善

2016/12/20 08:17

投稿

cookie.
cookie.

スコア14

test CHANGED
File without changes
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  よろしくお願いします。
24
24
 
25
-
25
+ 、、、PHP
26
26
 
27
27
  index.php
28
28
 
@@ -56,7 +56,9 @@
56
56
 
57
57
 
58
58
 
59
+ try { if($_SERVER['REQUEST_METHOD'] === 'POST') {
60
+
59
- try { //SQLに接続
61
+ //SQLに接続
60
62
 
61
63
  $pdo = new PDO($dsn, $user, $password);
62
64
 
@@ -80,7 +82,11 @@
80
82
 
81
83
  $stm->bindValue(':comment', $comment, PDO::PARAM_STR);
82
84
 
85
+ $stm->execute()
83
86
 
87
+ }
88
+
89
+ else{
84
90
 
85
91
  if ($stm->execute()){
86
92
 
@@ -114,6 +120,8 @@
114
120
 
115
121
  };
116
122
 
123
+ }
124
+
117
125
  } catch (Exception $e) {
118
126
 
119
127
  echo 'エラーがありました。<br>';
@@ -129,3 +137,5 @@
129
137
 
130
138
 
131
139
  </body>
140
+
141
+ 、、、

1

文章の改善

2016/12/20 08:16

投稿

cookie.
cookie.

スコア14

test CHANGED
File without changes
test CHANGED
@@ -6,15 +6,15 @@
6
6
 
7
7
  掲示板を作ろうとしているのですが、
8
8
 
9
- リロの防ができなくて困っています。
9
+ 投稿した後にそのままペジ更新をした際同じ投稿がされるぎたいのですができなくて困っています。
10
10
 
11
11
  下記の記述途中のコードのどこにどのような関数を置けばいいのかがわかりません。
12
12
 
13
13
 
14
14
 
15
- 浅い知識の中で、今まで自分が調べた中では、header('Location:絶対パス',true,303);
15
+ 自分の浅い知識の中で、今までが調べた中では、header('Location:絶対パス',true,303);
16
16
 
17
- を置けばリロード防止できるのではないかと思い、何度も位置を変え記述を変えしているのですが、上手くいきません。
17
+ を置けば上記のリロードによる二重送信を防止できるのではないかと思い、何度も位置を変え記述を変えしているのですが、上手くいきません。
18
18
 
19
19
 
20
20