Requirement
CodeIgniterjQuery
Our last screen shot
Create a folder named js in your root directory and then download the jQuery file below your js folder. Rename it as jquery.js. And then link this file in our header_view.php like following.
<script type="text/javascript" src="<?php echo base_url();?>js/jquery.js"></script>
Editing registration_view file for ajax validation
Firstly I add the span class to the user_name input field to show our yes or no picture like following.<p> <label for="user_name">User Name:</label> <input type="text" id="user_name" name="user_name" value="<?php echo set_value('user_name'); ?>" /><span id="usr_verify" class="verify"></span> </p>
<script type="text/javascript"> $(document).ready(function(){ $("#user_name").keyup(function(){ if($("#user_name").val().length >= 4) { $.ajax({ type: "POST", url: "<?php echo base_url();?>index.php/user/check_user", data: "name="+$("#user_name").val(), success: function(msg){ if(msg=="true") { $("#usr_verify").css({ "background-image": "url('<?php echo base_url();?>images/yes.png')" }); } else { $("#usr_verify").css({ "background-image": "url('<?php echo base_url();?>images/no.png')" }); } } }); } else { $("#usr_verify").css({ "background-image": "none" }); } }); }); </script>
public function check_user() { $usr=$this->input->post('name'); $result=$this->user_model->check_user_exist($usr); if($result) { echo "false"; } else{ echo "true"; } }
Now we need to create the check_user_exist() model function. Add following function to our user_model model.
public function check_user_exist($usr) { $this->db->where("username",$usr); $query=$this->db->get("user"); if($query->num_rows()>0) { return true; } else { return false; } }
.verify { margin-top: 4px; margin-left: 9px; position: absolute; width: 16px; height: 16px; }
Download Source Code
nice stuff...thanks
ReplyDeleteThank You !!
ReplyDeletegreat tutorial
ReplyDeleteThanks it is very help full for me.
ReplyDeletethanks, very good tutorial. help full
ReplyDeleteGreat series!!
ReplyDeleteCorrect me if i'm wrong, but you can still post the form and it will enter?
ReplyDeleteYes ... It just indicates error .. do not prevent from submitting form.
Deletethanx very good tutorial
ReplyDeleteThanks a lot
ReplyDeleteweak
ReplyDeletewhere is data base file..........
ReplyDeleteCREATE TABLE `user` (
Delete`id` INT( 50 ) NOT NULL AUTO_INCREMENT ,
`username` VARCHAR( 50 ) NOT NULL ,
`email` VARCHAR( 100 ) NOT NULL ,
`password` VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = InnoDB
source:http://tutsforweb.blogspot.com/2012/05/user-registration-with-codeigniter.html
This comment has been removed by the author.
ReplyDeletethanks, very good tutorial.
ReplyDeletevery helpfull
thanx very good tutorial
ReplyDeletevery help full code for beginners ,
ReplyDeletethanks
thank you guys...
ReplyDeletewow Thank you
ReplyDeletenice tutorial
ReplyDeleteThanks, it's very helpful.
ReplyDeleteNice Stuff..!! Thanks a lot :)
ReplyDeleteThanks for this code!!!!.easy to understand
ReplyDeletenice
ReplyDeleteThank you for sharing; it’s nice and helpful information. I hope I could read more information like this in the next visit.
ReplyDeleteregards,
SEO melbourne
Vmware Training in Chennai
ReplyDeleteWeb Designing Training in Chennai
AWS Training in Chennai
Linux Training in Chennai
Microsoft Azure Training in Chennai
This comment has been removed by the author.
ReplyDeleteIt's wonderful you write.
ReplyDeleteAnna
This is my 1st visit to your web... But I'm so impressed with your content. Good Job!
ReplyDeletepython course institute in bangalore
python Course in bangalore
python training institute in bangalore
Thanks For Sharing The Information The Information shared Is Very Valuable Please Keep Updating Us Time Just Went On reading The Article Python Online Training Aws Online Course DataScience Online Course Devops Online Course
ReplyDeleteSuperb blog I visit this blog it's extremely marvelous. Interestingly, in this blog content composed plainly and justifiable. The substance of data is exceptionally instructive.
ReplyDeleteoracle fusion financials classroom training
Workday HCM Online Training
Oracle Fusion Financials Online Training
Oracle Fusion HCM Online Training
Oracle Fusion SCM Online Training
Oracle Fusion HCM Classroom Training
Uw artikel is zeer betekenisvol
ReplyDeletechó Corgi
bán chó Corgi
chó Corgi giá bao nhiêu
mua chó Corgi
python training in bangalore | python online training
ReplyDeleteaws online training in bangalore | aws online training
artificial intelligence training in bangalore | artificial intelligence online training
machine learning training in bangalore | machine learning online training
data science training in bangalore | data science online training