0
我與代碼的控制器:寄存器形式卸載很好
function register()
{
$this->load->view('backend/register');
}
我有一個表格(register.php)與工作良好。我需要在控制器中加載此代碼:
$names = $this->input->post('name');
$birthday = $this->input->post('birthday');
$phones = $this->input->post('phone');
$emails = $this->input->post('email');
$passwords = $this->input->post('password');
$rolls = '0';
$data['name'] = $names;
$data['email'] = $emails;
$data['password'] = sha1($passwords);
$data['phone'] = $phones;
$data['birthday'] = $birthday;
//validate here, if the row(name, email, password) is empty or not
if($data['name'] == '' || $data['email'] == '' || $data['password'] == '')
continue;
$this->db->insert('student' , $data);
$student_id = $this->db->insert_id();
$data2['enroll_code'] = substr(md5(rand(0, 1000000)), 0, 7);
$data2['student_id'] = $student_id;
$data2['class_id'] = $this->input->post('class_id');
if($this->input->post('section_id') != '') {
$data2['section_id'] = $this->input->post('section_id');
}
$data2['roll'] = $rolls[$i];
$data2['date_added'] = strtotime(date("Y-m-d H:i:s"));
$data2['year'] = $this->db->get_where('settings' , array(
'type' => 'running_year'
))->row()->description;
$this->db->insert('enroll' , $data2);
echo 'alert("Contul a fost creat cu succes!")';
redirect(base_url() . 'index.php?login/' , 'refresh');
在控制器的當前窗體中加載的頁面非常好。當我添加上面的代碼時,頁面不再加載。我試圖從控制器中刪除代碼行($ this-> load-> view('backend/register');)+添加了我想要但沒有結果的代碼。 如何結合上面的代碼工作?
閱讀此https://www.codeigniter.com/user_guide/libraries/form_validation.html併爲您的密碼使用http://php.net/manual/en/function.password-hash.php和http: //php.net/manual/en/function.password-verify.php也https://www.codeigniter.com/user_guide/general/controllers.html – user4419336
你說如果用戶註冊他/她應該被重定向到'在將用戶詳細信息插入到數據庫後,登錄頁面顯示註冊頁面? – Regolith