我想在用戶授權時將用戶引導到我的主頁面。我做我的login_check控制器用戶檢查和添加$this->load->view('main');
該頁面可以是負載,但在主要頁面的網站地址仍然顯示codeigniter重定向到不同的控制器
,但我想讓它顯示
我必須創建一個新的'主'控制器並加載視圖嗎?這對我來說聽起來多餘。這是我的代碼。我login_check.php
private function _user_check()
{
$this->load->model('user_query'); //load my model
$result=$this->user_query->query($this->input->post('username'),$this->input->post('password'))
if($result) //the user is in DB
{
$data['view']='main';
$this->load->view('include/template', $data);
//the address bar shows http://myproject/login_check in main page
}else{ //the user is not in DB
$data['view']='login';
$this->load->view('include/template', $data);
}
}
上的方法。當你說要發送的型號,平均form_validation之前「過程/檢查」?如果是這樣,我已經在代碼的其他部分做了它。我需要做mysql_real_escape_string嗎?我認爲Codeigniter已經應用了它,因爲我使用$ this-> input-> post。 Thans。 – FlyingCat
不,你好,那麼如果你使用** Active Queries **,CI會照顧所有這些,但是如果你自己編寫SQL查詢,你需要使用'$ this-> db-> escape()'來逃避你的說'用戶名'或'密碼'以防萬一(從不傷害額外準備) – Jakub
好的。謝謝您的幫助。 :D – FlyingCat