cakephp3を使用してサイトを作ることになったのですが、オブジェクト指向も理解できていなく、簡単な値の受け渡しもできない状況です。
index.ctpがform画面で、sendform.ctpで結果を表示しています。
TestController.php
<?php namespace App\Controller; use App\Controller\AppController; class TestsController extends AppController{ public $name="Tests"; //public $autoRender="true"; public $autoRender=true; function index(){} function sendform(){ //ページタイトル $textname=$this->request->data('textname'); if($textname!="" && isset($textname)){ $reslt="you name:".$textname; }else{ $result="未入力です"; } $this->set("result",$result); } } ?>
index.ctp
<?php // app/View/Tests/index.ctp ?> <html> <head> <title>skima</title> </head> <body> <form method="post" action="/tests/sendform"> <input type="text" name="textname"> <input type="submit" value="送信"> </form> </body> </html>
senfform.ctp
<?php // app/View/Tests/index.ctp ?> <html> <head> <title>skima</title> </head> <body> <p>結果</p> <?php print($result); ?> </body> </html>
この結果が未入力になってしまいます。
debug($this->request->data);としてもnullになります。
ちなみにこのdebutはvar_dumpと同じ認識でしょうか?
また、index.ctpというファイルからController.phpにリクエストを送って、次にsendform.ctpに値を送っているとういう認識で間違っていないでしょうか?
今までオプジェクト指向も使っていないやり方で自由に作ってしまっていたので、やり方の違いに戸惑っています。
だいたいどのくらいで習得できるものなのでしょうか...
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/18 09:23