質問編集履歴

1

文法の修正

2020/08/24 12:35

投稿

allfree
allfree

スコア3

test CHANGED
File without changes
test CHANGED
@@ -68,7 +68,7 @@
68
68
 
69
69
  //テーブルの作成
70
70
 
71
- $sql = "CREATE TABLE IF NOT EXISTS keiziban_txt"
71
+ $sql = "CREATE TABLE IF NOT EXISTS tech_text"
72
72
 
73
73
  ."("
74
74
 
@@ -94,13 +94,13 @@
94
94
 
95
95
  //編集選択機能
96
96
 
97
- if(!empty($_POST["edit"]) && !empty($_POST["editpass"])){
97
+ if(!empty($_POST["editNo"]) && !empty($_POST["editpass"])){
98
-
98
+
99
- $id = $_POST["edit"];
99
+ $id = $_POST["editNo"];
100
100
 
101
101
  $editpass = $_POST["editpass"];
102
102
 
103
- $sql = 'SELECT * FROM keiziban_test';
103
+ $sql = 'SELECT * FROM tech_text';
104
104
 
105
105
  $stmt = $pdo->query($sql);
106
106
 
@@ -118,7 +118,7 @@
118
118
 
119
119
  $pass = $row['pass'];
120
120
 
121
- $enumber = $row['id'];
121
+ $editnumber = $row['id'];
122
122
 
123
123
  }
124
124
 
@@ -144,7 +144,7 @@
144
144
 
145
145
  <input id="pass" type = "text" name = "password" value ="<?php if(!empty($pass)){echo $pass;}?>" placeholder = "<?php if(empty($pass)){echo "パスワード";}?>">
146
146
 
147
- <input type = "hidden" name = "edit-number" value = "<?php if(!empty($pass)){echo $enumber;}?>" >
147
+ <input type = "hidden" name = "edit-number" value = "<?php if(!empty($pass)){echo $editnumber;}?>" >
148
148
 
149
149
  <input type = "submit" name = "btn"value = "送信"><br>
150
150
 
@@ -158,7 +158,7 @@
158
158
 
159
159
 
160
160
 
161
- <input type = "text" name = "edit" placeholder = "編集対象番号" placeholder="編集番号を入力してください">
161
+ <input type = "text" name = "editNo" placeholder = "編集対象番号" placeholder="編集番号を入力してください">
162
162
 
163
163
  <input id="pass" type = "text" name = "editpass" placeholder = "パスワード">
164
164
 
@@ -180,31 +180,31 @@
180
180
 
181
181
  //編集実行機能
182
182
 
183
- if(!empty($_POST["edit-number"]) && !empty($_POST["edit"])){
183
+ if(!empty($_POST["edit-number"]) && !empty($_POST["editNo"])){
184
-
184
+
185
- $editid = $_POST["edit-number"]; //ここで編集対象番号の値の受け取りを行う
185
+ $id = $_POST["edit-number"]; //ここで編集対象番号の値の受け取りを行う
186
-
186
+
187
- $editname = $_POST["name"];
187
+ $name = $_POST["name"];
188
-
188
+
189
- $editcomment = $_POST["comment"];
189
+ $comment = $_POST["comment"];
190
-
190
+
191
- $editpassword = $_POST["password"];
191
+ $password = $_POST["password"];
192
-
192
+
193
- $editdate = date("Y年m月d日 H時i分s秒");
193
+ $date = date("Y年m月d日 H時i分s秒");
194
-
194
+
195
- $sql = 'update tb_test set name=:name,comment=:comment,pass=:pass,date=date where id=:id';
195
+ $sql = 'update tech_text set name=:name,comment=:comment,pass=:pass,date=date where id=:id';
196
196
 
197
197
  $stmt = $pdo->prepare($sql);
198
198
 
199
- $stmt->bindParam(':name', $editname, PDO::PARAM_STR);
199
+ $stmt->bindParam(':name', $name, PDO::PARAM_STR);
200
-
200
+
201
- $stmt->bindParam(':comment', $editcomment, PDO::PARAM_STR);
201
+ $stmt->bindParam(':comment', $comment, PDO::PARAM_STR);
202
-
202
+
203
- $stmt->bindParam(':pass', $editpassword, PDO::PARAM_STR);
203
+ $stmt->bindParam(':pass', $password, PDO::PARAM_STR);
204
-
204
+
205
- $stmt->bindParam(':date', $editdate, PDO::PARAM_STR);
205
+ $stmt->bindParam(':date', $date, PDO::PARAM_STR);
206
-
206
+
207
- $stmt->bindParam(':id', $editid, PDO::PARAM_INT);
207
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
208
208
 
209
209
  $stmt->execute();
210
210
 
@@ -230,7 +230,7 @@
230
230
 
231
231
  $date = date("Y年m月d日 H時i分s秒");
232
232
 
233
- $sql = $pdo -> prepare("INSERT INTO tb_test (name, comment, pass,date) VALUES(:name, :comment, :pass,:date)");
233
+ $sql = $pdo -> prepare("INSERT INTO tech_text (name, comment, pass,date) VALUES(:name, :comment, :pass,:date)");
234
234
 
235
235
  $sql -> bindParam(':name', $name, PDO::PARAM_STR);
236
236
 
@@ -256,7 +256,7 @@
256
256
 
257
257
  $delpassword=$_POST['delpass'] ;
258
258
 
259
- $sql = 'delete from tb_test where id=:id';
259
+ $sql = 'delete from tech_text where id=:id';
260
260
 
261
261
  $stmt = $pdo->prepare($sql);
262
262
 
@@ -274,7 +274,7 @@
274
274
 
275
275
 
276
276
 
277
- $sql = 'SELECT * FROM tb_test';
277
+ $sql = 'SELECT * FROM tech_text';
278
278
 
279
279
  $stmt = $pdo->query($sql);
280
280