質問編集履歴
1
加筆
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,3 +19,227 @@
|
|
19
19
|
|
20
20
|
|
21
21
|
よろしくお願いいたします。
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
〇追記:コード例
|
26
|
+
|
27
|
+
検証用に作成したコード、フレームワークcodeigniterを使用しています。
|
28
|
+
|
29
|
+
処理の流れは以下の感じ
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
1.申し込み画面(entry.php)
|
34
|
+
|
35
|
+
2.申し込みボタンを押してPOST
|
36
|
+
|
37
|
+
3.サーバー側で登録後、リダイレクト(Location: http://root/recruit/entry/complete_entry)
|
38
|
+
|
39
|
+
4.クライアントリダイレクト要求を受け取ってhttp://root/recruit/entry/complete_entryにリクエスト
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
ここで2のリファラが残らないのはなぜでしょうか。
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
```PHP
|
48
|
+
|
49
|
+
<!--view/entry.php-->
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
<?php echo validation_errors(); ?>
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
<?php echo form_open('entry/post'); ?>
|
58
|
+
|
59
|
+
<div class="wrapper">
|
60
|
+
|
61
|
+
<div class="entry_contents">
|
62
|
+
|
63
|
+
<div class="contents_label">
|
64
|
+
|
65
|
+
<label>お名前</label>
|
66
|
+
|
67
|
+
</div>
|
68
|
+
|
69
|
+
<div>
|
70
|
+
|
71
|
+
<input type="text" name="last_name" />
|
72
|
+
|
73
|
+
<input type="text" name="first_name" />
|
74
|
+
|
75
|
+
</div>
|
76
|
+
|
77
|
+
</div>
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div class="entry_contents">
|
82
|
+
|
83
|
+
<div class="contents_label">
|
84
|
+
|
85
|
+
<label>メールアドレス</label>
|
86
|
+
|
87
|
+
</div>
|
88
|
+
|
89
|
+
<div>
|
90
|
+
|
91
|
+
<input type="email" name="email" />
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
</div>
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<div class="entry_contents">
|
100
|
+
|
101
|
+
<div class="contents_label">
|
102
|
+
|
103
|
+
<label>電話番号</label>
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
<div>
|
108
|
+
|
109
|
+
<input type="text" name="phone_num" />
|
110
|
+
|
111
|
+
</div>
|
112
|
+
|
113
|
+
</div>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
<input type="submit" name="post" value="申し込み"/>
|
118
|
+
|
119
|
+
</div>
|
120
|
+
|
121
|
+
</form>
|
122
|
+
|
123
|
+
```
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
```PHP
|
130
|
+
|
131
|
+
<?PHP
|
132
|
+
|
133
|
+
<!--controller/Entry.php-->
|
134
|
+
|
135
|
+
class Entry extends CI_Controller {
|
136
|
+
|
137
|
+
public function __construct()
|
138
|
+
|
139
|
+
{
|
140
|
+
|
141
|
+
parent::__construct();
|
142
|
+
|
143
|
+
$this->load->helper('url_helper');
|
144
|
+
|
145
|
+
$this->load->helper('func');
|
146
|
+
|
147
|
+
$this->load->library('form_validation');
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
public function post()
|
154
|
+
|
155
|
+
{
|
156
|
+
|
157
|
+
// entryモデルクラスロード。指定はすべて小文字で指定
|
158
|
+
|
159
|
+
$this->load->model('entry_model');
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
// バリデーションルールセット
|
164
|
+
|
165
|
+
$this->form_validation->set_rules('last_name', '姓', 'required');
|
166
|
+
|
167
|
+
$this->form_validation->set_rules('first_name', '名', 'required');
|
168
|
+
|
169
|
+
$this->form_validation->set_rules('email', 'メールアドレス', 'required|valid_email');
|
170
|
+
|
171
|
+
$this->form_validation->set_rules('phone_num', '電話番号', 'required');
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
// バリデーションチェック
|
176
|
+
|
177
|
+
if ($this->form_validation->run() === FALSE) {
|
178
|
+
|
179
|
+
// チェックエラー
|
180
|
+
|
181
|
+
$this->view_wapper('entry');
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
} else {
|
186
|
+
|
187
|
+
// 正常系
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
//データ登録
|
192
|
+
|
193
|
+
$this->entry_model->create_entry();
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
//PRGパターン。リダイレクト
|
198
|
+
|
199
|
+
header("Location: http://root/recruit/entry/complete_entry", false, 303);
|
200
|
+
|
201
|
+
exit();
|
202
|
+
|
203
|
+
}
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
public function complete_entry()
|
210
|
+
|
211
|
+
{
|
212
|
+
|
213
|
+
$this->view_wapper('entry_done');
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
public function index()
|
220
|
+
|
221
|
+
{
|
222
|
+
|
223
|
+
$this->view_wapper('entry');
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
private function view_wapper($contents)
|
230
|
+
|
231
|
+
{
|
232
|
+
|
233
|
+
$this->load->view('templates/header');
|
234
|
+
|
235
|
+
$this->load->view($contents);
|
236
|
+
|
237
|
+
$this->load->view('templates/footer');
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
```
|