0
我試圖編輯鏈接以編輯用戶的信息。 ID爲1的用戶的網址爲用戶/編輯/ 1用於編輯信息的cakephp驗證組件
echo $this->Html->link('Edit Info', array(
'controller' => 'users',
'action' => 'edit',
AuthComponent::user('id')
));
該URL顯示正確。但是,我試圖限制它,只有具有該ID的用戶才能編輯他們的頁面。因此,假設用戶4嘗試編輯用戶1的信息,它將重定向。
這是應該重定向的UsersController中的編輯操作的一部分。
if($id !== AuthComponent::user('id')){
$this->redirect(array('controller'=>'posts','action'=> 'index'));
}
我收到以下錯誤
Parse error: syntax error, unexpected '=', expecting ')' in /Applications/XAMPP/xamppfiles/htdocs/cake/app/Controller/UsersController.php on line 42
編輯 - 得到它的工作,感謝您的幫助
我無法弄清楚如何與路線做,但我得到了它使用上述方法來工作。 – user1406951