我創建了該文件,甚至將代碼添加到了items_controller文件(我之前學習過,因爲不需要在普通PHP中執行此操作),但仍然收到一條消息,指出找不到新頁面。在CakePHP中創建新頁面
http://neighborrow.com/items/create/
誤差必須在items_controller
文件,因爲它的工作在調試模式,但是當我列出一個項目它顯示我從項目複製的確認消息/即使我編輯它創建添加頁面:
function create()
{
if(!empty($this->data))
{
if (!empty($this->data))
{
$user_error = false;
$this->Item->create();
if($this->Auth->user())
{
$user_id = $this->Auth->User('id');
}
else
{
if (!$user_id = $this->Item->User->is_user($this->data['Item']['user_email']))
{
$email = $this->data['Item']['user_email'];
// Create Password
$raw_password = $this->PasswordHelper->generatePassword();
// Has Password
$hashed_password = $this->Auth->password($raw_password);
// Add User
if (!$user_id = $this->Item->User->add_basic($email, $hashed_password))
$user_error = true;
// Login the User
$this->Auth->login(array('email' => $email, 'password' => $hashed_password));
// Send Registration Email
$this->Email->send_registration_email($email, $raw_password);
}
}
if(!$user_error)
{
$this->data['Item']['user_id'] = $user_id;
$this->data['Item']['approved'] = 1;
if ($this->Item->save($this->data))
{
$this->Session->setFlash('Congratulations on your first listing! After we review it to make sure it is rentable, we will send you your free profile where you can list, promote, and rent up to nine more items. Feel free to share you new listing right away! <a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>.');
$this->redirect(array('controller' => 'items', 'action' => 'view', $this->Item->id));
}
}
}
}
}
嘗試設置Configure :: write('debug',1);在config/core.php中,你可以看到來自CakePHP的錯誤消息。 – Oscar 2010-07-16 17:24:48
http://neighborrow.com/items/create/排序工作:)沒有告訴我爲什麼,只是顯示頁面現在...所以如果我刪除調試設置它會再次顯示錯誤? – adam 2010-07-16 17:33:33
老實說,你不知道你做了什麼或正在嘗試做什麼......似乎在你的網站上有所有類型的錯誤.. – Oscar 2010-07-16 17:45:55