View1.ctp라는보기가 있습니다.이보기에서 'captcha'라는 제어기 기능을 호출하는데보기는 captcha.ctp입니다. $ text라는 변수가 있습니다. view captcha.ctp. view1.ctp에서이 $ text 변수에 액세스하려고합니다. 어떻게해야합니까? (참고 : CakePHP의 버전 -2.3) 더 좋은 방법은 보안 문자를 설정하는 것입니다 View1.ctp
다른보기에서보기 변수에 액세스하기 --Cakephp
<h1>Add Comment</h1>
<?php
$post_id= $posts['Post']['id'];
echo $this->Form->create('Comment',array('action' => 'comment','url' => array($post_id,$flag)));
echo $this->Form->input('name');
echo $this->Form->input('email');
echo $this->Form->input('text', array('rows' => '3'));
echo "Enter Captcha Code: ";
echo $this->Html->image(
array('controller' => 'posts', 'action' => 'captcha'));
echo $this->Form->input('code');
echo $this->Form->end('Add comment');
?>
captcha.ctp:
<?php
$this->Session->read();
$text = rand(10000,99996);
$_SESSION["vercode"] = $text;
$height = 25;
$width = 65;
$image_p = imagecreate($width, $height);
$black = imagecolorallocate($image_p, 0, 0, 0);
$white = imagecolorallocate($image_p, 255, 255, 255);
$font_size = 14;
imagestring($image_p, $font_size, 5, 5, $text, $white);
imagejpeg($image_p, null, 80);
?>
덕분에 많이. 시도해 보니 선생님 – user1479469
알 수 있지만 다른 컨트롤러에서이 vercode에 액세스해야합니다. CommentsController.php PostsController.ctp가 아닙니다. – user1479469
이 오류가 발생합니다. 오류 : 부재 기능 호출 non-object에서 read()를 호출한다. – user1479469