Sunday 17 August 2014

Email availability checking in codeigniter.

Posted by Unknown  |  No comments


Email-ID:
            In View Page  Jquery validation for the field:
           rules: {
          userEmail :{
               required: true,
               email: true,
               remote: "<?=base_url()?>user/checkUserEmail" //here i am calling controller name
                        }
                  },


       messages: {
      userEmail:{
         required: "Please enter your email",
         email: "Email must be in the format of name@domain.com",
          remote: "Email Id already exist"
                   }
                      };
-------------------------------------------------------------------------------------------------------------------
Controller:
       Add the following function in your Controller
               
          function checkUserEmail(){
      $userEmail = $this->input->get("userEmail");
       $count = $this->user_model->GetUser(array("userEmail"=>$userEmail));
       if(count($count) == 0){
echo "true"; //The User Email is not available.
          }
                            else{
echo "false"; //The User Email is already taken.
                  }
                                                 }
---------------------------------------------------------------------------------------------------------------------
Model:
       Add the following function in your model file
     function GetUser($options = array()){

if(isset($options['userEmail']))
$this->db->where('userEmail', strip_tags($options['userEmail']));


                                                   }


              


04:47 Share:

0 comments:

Get updates in your email box
Complete the form below, and we'll send you the best coupons.

Deliver via FeedBurner
Proudly Powered by Blogger.
back to top