Added: 2 years ago
From: Verbloten
Views: 10,034
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (16)

Sign In or Sign Up now to post a comment!
  • 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]

  • @nalixl

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

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

  • Nicely done!

  • '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

  • @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!

  • Comment removed

  • Comment removed

  • Pro

  • Nice!!! waiting for parts 6 7 8 9 10!!!!!

  • Thanks, this was very helpful.

    More please!!

  • AWESOME tutorial. I'm new to CI so I found this super useful, so please add on part 6 and part 7. Very appreicate!!!

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