我正在創建一個表單,我想製作一個自定義錯誤日誌,例如當用戶離開電子郵件爲空時,我想給我的error_helper可變的電子郵件,發送給用戶,他沒有填寫這個變量,並記錄他留下這個空的。我是codeIgniter的入門者,我已閱讀手冊,但沒有找到有用的東西。這裏是我的代碼:你可以給幫手一個變量,並改變它在CodeIgniter中使用的函數
public function submitCheck() {
$this->load->model("User");
if(empty($post['email'] || 'email'==""))
{
echo "Email is empty."; //This will be changed to a view for user
$this->load->helper('error'); //Loading the helper
errorLog('Firstname'); //Variable I want to give to the errorLog function.
exit();
}
所以在這裏我給我的錯誤日誌的變量,至極我想在我error_helper使用
function errorLog(){
if(errorLog() == 'email') //Here I want to change the error function based on what variable I give to errorLog
{
log_message('error', 'Email was empty');
exit();
}
}
這是可能做或一些其他的方式怎麼可以根據我給我的errorLog變量來改變函數。 在此先感謝
這個工作對我來說,非常感謝!你的意思是我需要創建一個控制器構造函數或在我自己的控制器中創建一個? (對不起noob問題) – RDAxRoadkill