Php 如何在Codeigniter中验证电子邮件重复条目
我需要帮助来验证电子邮件,请教我如何验证 插入现有电子邮件后出现数据库错误:Php 如何在Codeigniter中验证电子邮件重复条目,php,sql,codeigniter,validation,Php,Sql,Codeigniter,Validation,我需要帮助来验证电子邮件,请教我如何验证 插入现有电子邮件后出现数据库错误: 图片: 用于添加用户的创建代码 function student($param1 = '', $param2 = '', $param3 = '') { if ($this->session->userdata('admin_login') != 1) redirect('login', 'refresh'); if ($param1 == 'create') {
图片: 用于添加用户的创建代码
function student($param1 = '', $param2 = '', $param3 = '')
{
if ($this->session->userdata('admin_login') != 1)
redirect('login', 'refresh');
if ($param1 == 'create') {
$data['name'] = $this->input->post('name');
$data['mname'] = $this->input->post('mname');
$data['lastname'] = $this->input->post('lastname');
$data['birthday'] = $this->input->post('birthday');
$data['sex'] = $this->input->post('sex');
$data['address'] = $this->input->post('address');
$data['phone'] = $this->input->post('phone');
$data['email'] = $this->input->post('email');
$data['password'] = md5($this->input->post('password'));
$data['father_name'] = $this->input->post('father_name');
$data['mother_name'] = $this->input->post('mother_name');
$data['class_id'] = $this->input->post('class_id');
$data['roll'] = $this->input->post('roll');
$this->db->insert('student', $data);
$student_id = mysql_insert_id();
move_uploaded_file($_FILES['userfile']['tmp_name'], 'uploads/student_image/' . $student_id . '.jpg');
$this->email_model->account_opening_email('student', $data['email']); //SEND EMAIL ACCOUNT OPENING EMAIL
$this->session->set_flashdata('flash_message', get_phrase('add_student_success'));
redirect(base_url() . 'index.php?admin/student/' . $data['class_id'], 'refresh');
}
定义表单时,为
is\u unique
$this->form_validation->set_rules('email', 'Email', 'required|is_unique[users.email]');
我想把图片添加到帖子正文中,但它的质量太差了。你能发布一个更好的吗?对不起,我需要10个声誉才能在这里发布新的图像,所以你有codeigniter供你使用,但你坚持使用不推荐的、不安全的
mysql.*
estension?对不起,帮你修复这个密码就像给自杀的人注射氰化物。我没有参与其中。哦:不要喷标签:JavaScript标签不适用于你的问题,所以不要添加它。你不能只使用mysql\u insert\u id()。尝试$this->db->insert_id()
。与问题无关,但通过$student_id=$this->db->insert('student',$data)->insert_id()
,获取学生id更安全。很抱歉,我不知道我把代码放在哪里了:(@KarlGötze你在使用表单库吗?我不知道codeigniter中的表单库是什么?@KarlGötze好的,请看手册。它允许你向表单中的每个字段添加验证器。这太难了。而且需要时间:(我不知道怎么做。我很抱歉