편집 1 : 내 디렉토리가 www/cake/cake2.1/app 일 때 제대로 작동하지만 www/cake/app가 아래 문제에 직면했을 때.cake php가 빈 페이지로 리디렉션됩니다.
안녕하세요, 저는 PHP로 시작한 블로그 튜토리얼을 블로그에서 시작했습니다. 나는 모든 단계를 따라 튜토리얼에 따라 형식을 만들고 db에 값을 저장하려고합니다.
문제는 값이 Db에 저장되지만 빈 페이지로 리디렉션된다는 것입니다.
컨트롤러 :이 URL을 hxxp에 빈 페이지를 표시 리디렉션이 제대로 발생되지
<?php
class PostsController extends AppController {
public $helpers = array('Html', 'Form');
public function index(){
$this->set('posts', $this->Post->find('all'));
}
function view($id = null) {
$this->Post->id = $id;
$this->set('post', $this->Post->read());
}
function add(){
if($this->request->is('post')){
if($this->Post->save($this->request->data)){
$this->Session->setFlash('Your post has been saved.');
$this->redirect(array('action'=>'index'));
}else{
$this->Session->setFlash('Unable to add your post.');
}
}
}
}
: // localhost를/케이크/게시물/
도 $this->redirect('http://www.google.com');
을 시도하지 않는 추가 도움이 필요한 사람이 있습니까?
포스트 모델 :
<?php
class Post extends AppModel {
public $validate = array(
'title' => array(
'rule' => 'notEmpty'
),
'body' => array(
'rule' => 'notEmpty'
)
);
}
을 열심히하거나 당신이 리디렉션 (테스트 용)을 추가 기능의 시작에서 (저장하지 않고) 호출 할 때? –
게시물보기 페이지에서 색인으로 리디렉션하면 정상적으로 작동합니다. –