質問編集履歴

3

削除できないことを知らず、誤って投稿した為。

2016/05/15 17:04

投稿

earnest_gay
earnest_gay

スコア615

test CHANGED
@@ -1 +1 @@
1
- データベースに登録済みかを確認するに何故、レコード件数が必要なのか
1
+ 質問は誤って投稿されました。
test CHANGED
@@ -1,59 +1,5 @@
1
- 会員サイトにて、メールアドレス重複を避けるための方法につい調べてあるサンプルソースにどり着きなにやらレコード件数を取得していように見えるのでが...
1
+ 質問は誤っ投稿し質問内容が記録されていないため、このような表記なっておりま
2
2
 
3
3
 
4
4
 
5
- チェックしたいのは、
6
-
7
- ”フォームから入力されたアドレスとデータベースに登録されているアドレスの照合”
8
-
9
-
10
-
11
- なんですが、何故、レコード件数を取得する必要があるのでしょうか?
12
-
13
-
14
-
15
-
16
-
17
- ```
18
-
19
- ≪サンプルソース≫
20
-
21
-
22
-
23
- $sql = sprintf('SELECT COUNT(*) AS cnt FROM members WHERE email="%s"',
24
-
25
- mysqli_real_escape_string($db, $_POST['email'])
26
-
27
- );
28
-
29
- $record = mysqli_query($db, $sql) or die(mysqli_error($db));
30
-
31
- $table = mysqli_fetch_assoc($record);
32
-
33
- if ($table['cnt'] > 0) {
34
-
35
- $error['email'] = 'duplicate';
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
- <?php if ($error['email'] == 'duplicate'): ?>
46
-
47
- <p class="error">* 指定されたメールアドレスはすでに登録されています</p>
48
-
49
- <?php endif; ?>
50
-
51
- ```
52
-
53
-
54
-
55
- 最近勉強し始めて書籍だけでは理解が追い付いておりませんが、解説頂けると助かります。
56
-
57
-
58
-
59
- 宜しくお願いいたします。
5
+ ご容赦願います。

2

新しい質問が見つかった為

2016/05/15 17:04

投稿

earnest_gay
earnest_gay

スコア615

test CHANGED
@@ -1 +1 @@
1
- test
1
+ データベースに登録済みかを確認するのに何故、レコード件数が必要なのか
test CHANGED
@@ -1 +1,59 @@
1
+ 会員サイトにて、メールアドレスの重複を避けるための方法について調べてたら、あるサンプルソースにたどり着きなにやらレコード件数を取得しているように見えるのですが...
2
+
3
+
4
+
5
+ チェックしたいのは、
6
+
7
+ ”フォームから入力されたアドレスとデータベースに登録されているアドレスの照合”
8
+
9
+
10
+
11
+ なんですが、何故、レコード件数を取得する必要があるのでしょうか?
12
+
13
+
14
+
15
+
16
+
17
+ ```
18
+
19
+ ≪サンプルソース≫
20
+
21
+
22
+
1
- testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest
23
+ $sql = sprintf('SELECT COUNT(*) AS cnt FROM members WHERE email="%s"',
24
+
25
+ mysqli_real_escape_string($db, $_POST['email'])
26
+
27
+ );
28
+
29
+ $record = mysqli_query($db, $sql) or die(mysqli_error($db));
30
+
31
+ $table = mysqli_fetch_assoc($record);
32
+
33
+ if ($table['cnt'] > 0) {
34
+
35
+ $error['email'] = 'duplicate';
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+ <?php if ($error['email'] == 'duplicate'): ?>
46
+
47
+ <p class="error">* 指定されたメールアドレスはすでに登録されています</p>
48
+
49
+ <?php endif; ?>
50
+
51
+ ```
52
+
53
+
54
+
55
+ 最近勉強し始めて書籍だけでは理解が追い付いておりませんが、解説頂けると助かります。
56
+
57
+
58
+
59
+ 宜しくお願いいたします。

1

test

2016/05/15 16:46

投稿

earnest_gay
earnest_gay

スコア615

test CHANGED
@@ -1 +1 @@
1
- sessionについてです。
1
+ test
test CHANGED
@@ -1,123 +1 @@
1
- ある教材の一部です。
2
-
3
-
4
-
5
- ```
6
-
7
- ◆sample_input18.php
8
-
9
-
10
-
11
- <form action="sample18.php" method="post">
12
-
13
- <dl>
14
-
15
- <dt>ID</dt>
16
-
17
- <dd><input type="text" name="my_id" id="my_id" /></dd>
18
-
19
- <dt>パスワード</dt>
20
-
21
- <dd><input type="password" name="password" id="password" /></dd>
1
+ testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest
22
-
23
- </dl>
24
-
25
- <input type="submit" value="送信する" />
26
-
27
- </form>
28
-
29
- ```
30
-
31
-
32
-
33
- ```
34
-
35
- ◆sample18.php
36
-
37
-
38
-
39
- <?php
40
-
41
- session_start();
42
-
43
-
44
-
45
- if (isset($_POST['my_id'])) {
46
-
47
- $_SESSION['my_id'] = $_POST['my_id'];
48
-
49
- }
50
-
51
- ?>
52
-
53
-
54
-
55
- <p>ようこそ<?php echo htmlspecialchars($_SESSION['my_id']); ?>さん</p>
56
-
57
- <p><a href="./sample18_second.php">次のページへ</a></p>
58
-
59
- ```
60
-
61
-
62
-
63
- issetは中身があるかをチェックするかのもので分かります。
64
-
65
-
66
-
67
- その次の
68
-
69
-
70
-
71
- $_SESSION['my_id'] = $_POST['my_id'];
72
-
73
-
74
-
75
- がよくわかりません。
76
-
77
-
78
-
79
- そもそもif文の使い方として
80
-
81
-
82
-
83
- if (条件) {
84
-
85
- 処理;
86
-
87
- }
88
-
89
-
90
-
91
- だと思いますが、sample.phpの記述では
92
-
93
-
94
-
95
- if (条件) {
96
-
97
- 条件;
98
-
99
- }
100
-
101
-
102
-
103
- になってるように思えて理解できません。
104
-
105
-
106
-
107
-
108
-
109
- 処理はどこにいったのでしょうか?
110
-
111
-
112
-
113
- また、$_SESSION['my_id']のmy_idは、
114
-
115
-
116
-
117
- sample_input18.phpのinputのname属性のmy_idが使われているという認識で大丈夫でしょうか。
118
-
119
-
120
-
121
-
122
-
123
- 宜しくお願いいたします。