CodeIgniter Registration Form Part 5

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
10,268
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Aug 15, 2009

Part 5 of a series of tutorials on how to create a user registration form in CodeIgniter. This particular video covers form validation callback functions, where, in this case, we are checking to make sure that the username the user has chosen doesn't already exist in the database.

More CodeIgniter tutorials, all in one place, at http://www.simplycodeigniter.com.

Category:

Education

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (Verbloten)

  • 'username_not_exists' - pahaha.

    Alasdair I think I love you.

  • @ldexterldesign ok? I love you too?

  • is there a rule to achieve the behaviour opposite to "match"...for example suppose you dont want a username to be the same as your password (for security reasons), hence you would need an validation error to be thrown if both values equal.

    Is there a built in rule for that or would I have to write my own callback?

    THanks.

  • @mystiknrg You could create a custom rule or just do the following: In system/language/english (or as appropriate) /form_validation_lang.php add: $lang['not_matches']= "The %s field can not match the %s field."; In system/libraries/form_validati­on.php add: function not_matches($str, $field) { if ( ! isset($_POST[$field])) { return TRUE; } $field = $_POST[$field]; return ($str == $field) ? FALSE : TRUE; }
  • @Verbloten

    somewhere near function matches.

    Then in your form rules simply say not_matches[username] for the password field

see all

All Comments (16)

Sign In or Sign Up now to post a comment!
  • @nalixl

    $result = $this->db->query($query, $username);

    return ($result->num_rows() > 0) ? true : false;

  • Why work with if .. else .. statements in check_exists_username? Something like this seems more logical to me:

    [code]

    function check_exists_username($usernam­e){ $query_str = "blah"; $result = blah; if ($result->num_rows() == 0) return true; return false;

    }

    [/code]

  • Nicely done!

  • @Verbloten Oh wow..i didnt know it was that easy to extend the functionality of CI

    Thanks alot for your quick response!

  • Another excellent video. I learned a hell of a lot. Thanks very much!

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more