Kohana で POST メソッドを利用する。
- http://localhost/kohana/ を Kohana のルートとする
- POST データを投げる URL は http://localhost/kohana/index.php/post/recieve/ とする。
コントローラー名は「post」、メソッド名は「recieve」となる。
post.html
<form method="post" action="/kohana/index.php/post/recieve/"> <label for="mail">メールアドレス<br /> <input id="mail" type="text" name="mail"></label> <label for="name">名前<br /> <input id="name" type="text" name="mail"></label> <input type="submit" name="Submit"> </form>
post.php
<?php class Post_Controller extends Controller { public function recieve() { print_r($this->input->post()); echo $this->input->post('mail'); } ?>
出力結果は
Array ( [mail] => youraccount@localhost [name] => Your Name ) youraccount@localhost