質問するログイン新規登録

質問編集履歴

2

phpコードの名称追加

2023/07/28 05:12

投稿

kuregumo
kuregumo

スコア11

title CHANGED
File without changes
body CHANGED
@@ -73,7 +73,7 @@
73
73
  })
74
74
  </script>
75
75
  ```
76
-
76
+ server-login.php
77
77
  ```php
78
78
  <?php
79
79
 

1

コンソールログに表示された内容の追記

2023/07/28 04:45

投稿

kuregumo
kuregumo

スコア11

title CHANGED
File without changes
body CHANGED
@@ -139,3 +139,104 @@
139
139
  php v8.2.4
140
140
  jquery v3.2.1 min
141
141
 
142
+ ### コンソールログ表示
143
+ ```
144
+ <!DOCTYPE html>
145
+ <html>
146
+ <head>
147
+ <meta charset="UTF-8">
148
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
149
+ <title>タイトル</title>
150
+ {head}
151
+ <div class="body">
152
+ <form class="sign-body">
153
+ <div class="sign-heading">ログイン</div>
154
+ <table class="sign-table">
155
+ <tbody>
156
+ <!-- メールアドレス -->
157
+ <tr>
158
+ <td class="table-cap"><i class="fa-regular fa-envelope"></i>メールアドレス</td>
159
+ <td><input type="text" id="mail"></td>
160
+ </tr>
161
+ <tr>
162
+ <td class="caution-words no-mail hide" colspan="2">メールアドレスが入力されていません</td>
163
+ <td class="caution-words different-mail hide" colspan="2">メールアドレスが違います</td>
164
+ <td class="caution-words not-address hide" colspan="2">正しいメールアドレスを入力してください</td>
165
+ </tr>
166
+ <!-- パスワード -->
167
+ <tr>
168
+ <td><i class="fa-solid fa-key"></i>パスワード</td>
169
+ <td><input type="password" id="pass"></td>
170
+ </tr>
171
+ <tr>
172
+ <td class="caution-words no-pass hide" colspan="2">パスワードを入力してください</td>
173
+ <td class="caution-words different hide" colspan="2">メールアドレスまたはパスワードが違います</td>
174
+ </tr>
175
+ <tr>
176
+ <td class="table-cap"></td>
177
+ <td>
178
+ <a href="">パスワードをお忘れですか?</a>
179
+ </td>
180
+ </tr>
181
+ <!-- トークン -->
182
+ <input type="hidden" id="token" value="vTHSGG1eBUVwrF+EK5OoPBcUr+Wa+pRd0safZ1LAL/k=">
183
+ <tr>
184
+ <td class="table-cap"></td>
185
+ <td>
186
+ <input type="submit" id="send" value="ログイン">
187
+ </td>
188
+ </tr>
189
+ </tbody>
190
+ </table>
191
+ </form><script type="text/javascript">
192
+ $(function(){
193
+ //ログインボタンを押した時の動作
194
+ $('#send').click(function(){
195
+ //二重送信防止のためログインボタンの無効化
196
+ $('#send').prop('disabled', true);
197
+
198
+ //ajax通信するデータを作成
199
+ var userData = {
200
+ mail: $('#mail').val(),
201
+ pass: $('#pass').val(),
202
+ token: $('#token').val()
203
+ };
204
+ //ajax通信
205
+ $.ajax({
206
+ type: 'POST',
207
+ url: './login/server-login.php',
208
+ data: userData
209
+ }).done(function(data){
210
+ if(data == 'xsrf'){
211
+ alert('エラーが発生しました。もう一度やり直してください。');
212
+ location.href="/index.html";
213
+ return false;
214
+ }
215
+ $('.caution-words').addClass('hide');
216
+ if(data.indexOf('no-mail')>-1){
217
+ $('.no-mail').removeClass('hide');
218
+ }else if(data.indexOf('not-address')>-1){
219
+ $('.not-address').removeClass('hide');
220
+ }
221
+ if(data.indexOf('no-pass')>-1){
222
+ $('.no-pass').removeClass('hide');
223
+ }else if(data.indexOf('different')>-1){
224
+ $('.different').removeClass('hide');
225
+ }
226
+ $('#send').prop('disabled', false);
227
+ }).fail(function(XMLHttpRequest, textStatus, errorThrown) {
228
+ alert('error!!!');
229
+ console.log("XMLHttpRequest : " + XMLHttpRequest.status);
230
+ console.log("textStatus : " + textStatus);
231
+ console.log("errorThrown : " + errorThrown.message);
232
+ }).always(function(data) {
233
+ console.log(data);
234
+ });
235
+
236
+ })
237
+ })
238
+ </script> </div>
239
+
240
+ {footer}
241
+ </body></html>
242
+ ```