回答編集履歴

3

ちょうせい

2019/11/26 05:46

投稿

yambejp
yambejp

スコア114883

test CHANGED
@@ -62,7 +62,7 @@
62
62
 
63
63
  ```
64
64
 
65
- -受け側
65
+ - 受け側
66
66
 
67
67
  ```PHP
68
68
 

2

chousei

2019/11/26 05:46

投稿

yambejp
yambejp

スコア114883

test CHANGED
@@ -7,6 +7,8 @@
7
7
 
8
8
 
9
9
  # sample
10
+
11
+ - 送り側
10
12
 
11
13
  ```javascript
12
14
 
@@ -29,8 +31,6 @@
29
31
  });
30
32
 
31
33
  });
32
-
33
-
34
34
 
35
35
  </script>
36
36
 
@@ -61,3 +61,35 @@
61
61
  </div>
62
62
 
63
63
  ```
64
+
65
+ -受け側
66
+
67
+ ```PHP
68
+
69
+ <?PHP
70
+
71
+ $userid=filter_input(INPUT_POST,"userid");
72
+
73
+ $password=filter_input(INPUT_POST,"password");
74
+
75
+ if(is_null($userid) or is_null($password)){
76
+
77
+ print "不正";
78
+
79
+ }elseif($userid===""){
80
+
81
+ print "$_POST[userid]の値がありません";
82
+
83
+ }elseif($password===""){
84
+
85
+ print "$_POST[password]の値がありません";
86
+
87
+ }else{
88
+
89
+ print "POST_userid:".htmlspecialchars($userid)."<br>";
90
+
91
+ print "POST_password:".htmlspecialchars($password)."<br>";
92
+
93
+ }
94
+
95
+ ```

1

ちょうせい

2019/11/26 05:26

投稿

yambejp
yambejp

スコア114883

test CHANGED
@@ -3,3 +3,61 @@
3
3
  postformが呼び出されるたびにダミーでつくったフォームをサブミットしてますね
4
4
 
5
5
  またidを付加している部分も既存のidと競合しているように見えます
6
+
7
+
8
+
9
+ # sample
10
+
11
+ ```javascript
12
+
13
+ <script>
14
+
15
+ window.addEventListener('DOMContentLoaded', ()=>{
16
+
17
+ document.querySelector('form').addEventListener('submit',e=>{
18
+
19
+ var flg=Array.from(document.querySelectorAll('#userid,#password')).filter(x=>x.value=="").length>0;
20
+
21
+ if(flg){
22
+
23
+ alert("必須項目に空欄があります。");
24
+
25
+ e.preventDefault();
26
+
27
+ }
28
+
29
+ });
30
+
31
+ });
32
+
33
+
34
+
35
+ </script>
36
+
37
+ <div align="center">
38
+
39
+ <img src="ラックロゴ.png"></br>
40
+
41
+ <form method="post" action="customer_registration.php">
42
+
43
+ <div class="s14">ログインID</div>
44
+
45
+ <input type="text" id="userid" name ="userid" size="25">
46
+
47
+ <div class="s14">パスワード</div>
48
+
49
+ <input type="password" id="password" name ="password" size="25">
50
+
51
+ <div align="center">
52
+
53
+ <button class="button" type="submit">ログイン</button></br>
54
+
55
+ <button class="button" type="button">新規登録</button>
56
+
57
+ </div>
58
+
59
+ </form>
60
+
61
+ </div>
62
+
63
+ ```