2013-01-17 28 views
0

我使用tank auth在codeigniter中爲電子郵件驗證創建了一個回調函數。這裏是我的代碼:我得到未定義的變量而不是顯示錯誤消息

$this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean|valid_email|callback_is_email_domain[gmail.com,yahoo.com]'); 

function is_email_domain($input, $domain='') 
{ 
    $email_domain=explode("@", $input); 
    $domain = explode(",", $domain); 
    if(in_array($email_domain[1],$domain)) 
    { 
     $result=1; 
    } 

    else 
    { 
     $this->form_validation->set_message('is_email_domain', 'The %s field must be a %s email address'); 
    } 

    return $result; 
} 

我想罐權威性只允許「gmail.com」和「yahoo.com」電子郵件在我的網站註冊。

非常感謝!

+0

什麼是未定義變量? – newday

+0

@Menuka - $結果變量 – chums

回答

0
$email_domain is not an array but you have use it as an array `$email_domain[1]` 
+0

哦,呀!讓我再嘗試一次。謝謝! :) – chums

相關問題