Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>i am a huge fan of negative if checks. the idea is that if you do not get what you expect, you immediately exit. this can be getting back a result, or doing a true false check. Of course you are first going to validate the user name using CI form validation. so for example in your model, the method that checks for the user name - if the result is 0, just have it return false. Then in your controller:</p> <pre><code>// Validate the user name and other form info // if validation passes, grab the username, // note the TRUE, that tells CI to run it through XSS clean $username = $this-&gt;input-&gt;post( 'username', TRUE ) ; // if we did NOT get a user back from model, immediately go to new method if ( ! $user = $this-&gt;users_m-&gt;_findUser($username) ) { $this-&gt;_userNotFound(); } // similar, if the user account is locked, go to new method // if you return an array from model this would be $user['lock_date'] elseif ($this-&gt;isUserLocked($user-&gt;lock_date) == TRUE) { // DO NOT try and write messages etc here. put all that in a separate method $this-&gt;_userAccountLocked(); } else { // you have a $user and the user is not locked // its tempting to write a bunch of stuff here // do not do that. keep it clean, and go to separate method $this-&gt;_displayAccount($user) ; } </code></pre> <p>Note that i put an underscore before all the method names - CI will automatically make those private. Also note the Camel case for method names -- versus underscores. some people prefer it. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload