php - Checking validity of userid -


how display user exist when registering new user prevent same name registered many times.this model code.

class modeluser extends ci_model {  public function creataccount() {     $userid =   $_post['user_id'];     $password   =   sha1($_post['password']);      $this->form_validation->set_rules('user_id', 'userid',           trim|required|valid_userid|is_unique[account.user_id]|xss_clean');     if ($this->form_valudation == false)         return 'user exist'         }else    {      $this->db->query("insert account(user_id,password)     values ('$userid','$password'')");     } 

first have load form validation in constructor,

$this->load->library('form_validation'); 

now in creataccount function

public function creataccount() {     $userid =   $this->input->post('user_id');     $password   =   sha1( $this->input->post('password'));     $this->form_validation->set_rules('user_id','userid', 'trim|required|is_unique[tablename.coloumnname]|xss_clean');      if($this->form_validation->run() == true)         {     $this->db->query("insert account(user_id,password)     values ('$userid','$password')");              }else{          return false; }       } 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -