CodeIgniter From Scratch: Day 6

CodeIgniter From Scratch: Day 6 – Login

Sep 10th in Screencasts by Jeffrey Way

In today's hour long video tutorial, we'll be doing a lot! We'll implement a login and signup form that will allow us to lock down certain sections of our fictional site. As you'll find, working with sessions in CodeIgniter is a cinch!

PG

Author: Jeffrey Way

Hi, I'm Jeff. I'm the editor of Nettuts+, and the Site Manager of Theme Forest. I spend too much time in front of the computer and find myself telling my fiance', "We'll go in 5 minutes!" far too often. I just can't go out to dinner while I'm still producing FireBug errors...drives me crazy. During my free time, I sporadically write articles for my own personal blog. If it will keep you in the good graces of the church, follow us on Twitter.

Catch Up

Day 6: Sessions

Login Form
Signup Form

P.S. The Logout Button

I forgot to add the "logout" button during the screencast. There was so much to cover, that I was bound to forget something! Luckily, it's really easy. Simply add a link, to the "members" area, which links to the login class, and a "logout" method (login/logout). Then, all we must do is destroy the user's session, and redirect them back to the login form. Download the source code if confused.

function logout()
{
	$this->session->sess_destroy();
	$this->index();
}

Hope you Enjoy it!

Keep in mind that we're just scratching the surface, in terms of flexibility and security. We can - and very well may - take things much further. But this should get you started!

Thank you, Screencast.com!

Screencast.com
...for providing the hosting for these video tutorials.


Related Posts

Check out some more great tutorials and articles that you might like

Enjoy this Post?

Your vote will help us grow this site and provide even more awesomeness

Plus Members

Source Files, Bonus Tutorials and
More for $9 a month for all TUTS+
sites in one subscription.

Join Now

User Comments

( ADD YOURS )
  1. PG

    icantstop September 10th

    Thanks alot, Jeff! Maybe be will be good idea for the next screencast to show how implement and use ajax in CI?

    ( Reply )
    1. PG

      Shane September 11th

      That would be very good :)

      ( Reply )
    2. PG

      jeanv September 11th

      that would be great!!!!

      ( Reply )
    3. PG

      aryan September 11th

      I’ll also vote for AJAX. JQuery preferred.

      ( Reply )
      1. PG

        Anton Agestam September 13th

        1 up for jQuery!

    4. PG

      fluxish September 12th

      yes, ajax please! Also I prefer jquery

      ( Reply )
    5. PG

      Anmol September 12th

      Yea, Please Please try to show how to use Ajax in code Igniter

      ( Reply )
    6. PG

      Vishal September 12th

      Yes please some AJAX stuff :-) am up for it too

      ( Reply )
      1. PG

        arnold September 13th

        good idea icantstop…jquery + ajax…hopefully

    7. PG

      Nick September 14th

      One more vote for ajax + jquery :)

      ( Reply )
    8. PG

      Baylor Rae' October 3rd

      Yes, please add a video on implementing jQuery in CI

      ( Reply )
    9. PG

      Vincent November 1st

      AJAX & jQuery +1!

      That would be great ;)

      BTW, thanks for all the effort you put in these screencasts !

      ( Reply )
  2. PG

    Carlos Caniguante September 10th

    At Last!!!! being waiting this all week :)
    Thank You!

    PD: Hey Jeff It’s seems that your personal domaing http://www.jeff-way.com/ has expired.

    ( Reply )
  3. PG

    Hooman Asgari September 10th

    Thanks
    been waiting for this episode
    Thanks Jeff
    Thanks Envato for teaching us all the good stuff
    Look forward for the nex one too

    ( Reply )
  4. PG

    Juan C Rois September 10th

    I’ve been looking into CodeIgniter for a while. This and all the previous posts will be very handy when I take the plunge.

    Thanks Jeff

    ( Reply )
  5. PG

    Mathew Davies September 10th

    This is no good, hashing a password with 1 pass of md5 without a salt is not a good idea. Once your database is hacked, hackers can easily look up passwords via a rainbow table. Please reconsider your security implementation.

    There are a number of other issues I would fix.

    1. Hard-coded link in the “is_logged_in” method.
    2. The “is_logged_in” method should be in a library. No need for it to be in a controller.
    3. Line 59 of the login controller, assigning the query variable in the “if” statement is pointless, you are not using it.
    4. Your logout method should redirect to your index page, not call it. You will end with 2 URLs with duplicate content otherwise.
    5. The validate method in the “membership_model” can be improved by changing this :

    if($query->num_rows == 1)
    {
    return true;
    }

    into this

    return (bool) $query->num_rows;

    6. This tutorial should be teaching best practices, including a header in multiple goes against the DRY mantra.

    -Mathew

    ( Reply )
    1. PG

      Jeffrey Way September 10th

      Your Md5 reference — For an introductory tutorial to a login system, it’ll work just fine. We’ll cover more advanced security steps in future tuts. You can only cover so much in one tutorial.

      ( Reply )
    2. PG

      Jeffrey Way September 10th

      Also…

      #2 – Well sure. But we can only cover so much in a short tutorial. :)

      #3 – Ahh good point. I must have revised the code, and forgotten that I don’t need to assign that value. Good eye.

      #5 – This is true, but we’ll be adding to this section in the next tutorial. That’s why I used the long form.

      #6 – Not sure what you’re referring to. We only reference the header from the template view. Did you watch the screencast?

      ( Reply )
      1. PG

        Mathew Davies September 10th

        For #6

        The login_form and signup_form views both include the header and footer files.

    3. PG

      Jeff September 10th

      You must have accidentally received an old file. I just downloaded the source code, and they aren’t there. Sorry for the confusion. :)

      ( Reply )
    4. PG

      Juan C Rois September 10th

      Mathew, I’m sure you are a seasoned coder, but many of us are just learning this stuff, which I believe is the point of the tutorial, I mean to get the basics.
      Thanks for pointing out this details, however I don’t think this tutorial is intended for real life implementations.
      In my case, I can’t wait to get to this level and hopefully one day I get to learn from one of your tutorials.

      Thanks everybody and keep up the good work.

      ( Reply )
      1. PG

        Alain September 11th

        I agree with Juan.

  6. PG

    Robert DeBoer September 10th

    I downloaded the movie, and it appears that there is voice problems – it will go out for some seconds and then come back in.

    ( Reply )
  7. PG

    Simon September 10th

    Hey, I just finished building a login / sign up system using codeigniter.

    A couple of days too late this tutorial.

    I’ll watch it anyway to see if there is anything I missed.

    ( Reply )
  8. PG

    Kamal El Fatihi September 10th

    thankyou thats so great i will just start read the post i just had the news by rss

    ( Reply )
  9. PG

    Nathan Ledet September 10th

    Thanks so much for this Jeff.

    I really am learning a lot about CodeIgniter, and programming logic in general, with these tutorials.

    Keep it up…they really are helpful and I can’t wait till next week!!!

    ( Reply )
  10. PG

    Guillermo Carrion September 10th

    Best Weekend gift ever! Specially since I have to give a 2-hour introductory tutorial about CodeIgniter to my fellow co-workers on Monday morning.

    Thanks a lot!

    :-)

    ( Reply )
  11. PG

    Ashit Vora September 10th

    Awesome. I have started loving CI. I was wondering if there’s any similar framework (easy to get started) for Java.

    ( Reply )
  12. PG

    Wiredesignz September 10th

    Don’t use the input object inside your models. Pass the data in.

    Models are not meant to be aware of the framework at all.

    ( Reply )
    1. PG

      eglyph September 18th

      +1 to this opinion. I would personally argue against using globals in the code. This way models aren’t portable across different projects, so better approach would to create model’s methods and pass data into it.

      ( Reply )
  13. PG

    Kevin Quillen September 10th

    Nice video Jeff. I would only recommend not to shoot around so fast with windows and app switching, even I got dizzy hah.

    CI looks nice.

    ( Reply )
  14. PG

    Javed Gardezi September 10th

    thank for this epi… waiting for this..
    Thanks a lot for providing download link :)

    Does it contain title for next epi???

    ( Reply )
  15. PG

    Hasanga September 10th

    Hi,

    Nice tut Jeff! very well done!

    How about a tutorial using a master page template with CI?
    ah! using jquery with CI to post form data also would be nice.

    ( Reply )
  16. PG

    Rahul September 10th

    Thanx a lot Jeff :)

    ( Reply )
  17. PG

    Kenshin September 11th

    I am very interested to see the advanced security CI tut :-)

    Thank you Jeffrey for the very good work!!!

    ( Reply )
  18. PG

    ricochet September 11th

    Thanks Jeffery!

    Do I just use the download link & give up checking iTunes from now on?

    ( Reply )
    1. PG

      macCesar September 11th

      Jeff… I have the same question here…

      day 5 never made it in iTunes…

      In fact.. The most recent video is dated is 8/24/09 (WordPress for Designers: Day 18)

      So what gives!!!!…

      ( Reply )
      1. PG

        Jeffrey Way September 11th

        I know – sorry guys. It’s a pain, because screencast.com doesn’t automatically submit to iTunes like Blip did. However, the quality is much, much higher. I’ll take care of the iTunes issue this weekend. :)

  19. PG

    ibura September 11th

    excellent!! as always

    ( Reply )
  20. PG

    Phil September 11th

    There’s an issue with CI Sessions in Internet Explorer (at least 6 and 7, but maybe 8 too), in that they don’t really work. There’s a library you can add to make it work properly, and all your code can remain the same. The library uses native PHP sessions, rather than CI’s version.

    There’s one on my blog for people that want it

    http://www.philsbury.co.uk/blog/code-igniter-sessions

    ( Reply )
  21. PG

    Fynn September 11th

    Great stuff! I’ve recently watched the first lessons of CodeIgniter (being a total CodeIgniter noob), and started creating my own CMS from what I’ve learned from your tuts and the great Code Igniter user guide! Been playing with it for a few weeks now and already learned a lot.

    Thanks Jef! Will watch this one tonight. Keep ‘um going.

    ( Reply )
  22. PG

    Carlos September 11th

    Nice tutorial, I have been waiting for this one!

    How about implementing a remember me, in the next tutorial?

    ( Reply )
  23. PG

    Shaun C. September 11th

    Awesome Jeffrey, pure awesomeness.

    ( Reply )
  24. PG

    Jaap Rood September 11th

    I’ve been following your CI tutorials, but this really was the one I was waiting for. Can’t wait to hear more on this topic!

    ( Reply )
  25. PG

    Mike September 11th

    Tutorial series that makes me wanna use CodeIgniter

    ( Reply )
  26. PG

    JT September 11th

    Your series is making me convert to Codeigniter! Thanks and keep up the great work Jeff!

    ( Reply )
  27. PG

    Myke Bates September 11th

    It would be awesome to see some examples of the new cart library releases in 1.7.2. Your tuts are amazing!

    ( Reply )
    1. PG

      Tutorial City September 14th

      I agree. A tutorial covering the cart class and a bit of an e-commerce website would be very cool.

      ( Reply )
  28. PG

    Benoit September 11th

    Thank you a lot Mr Way :D

    ( Reply )
  29. PG

    Bobbybazooka September 11th

    This is some great stuff. Kudos to Jeff.
    Would be nice with a part 2 were you show how to tighten the security and so on.

    ( Reply )
  30. PG

    Brian Gottier September 11th

    Wow, an hour long tutorial shows the pure dedication that you have to both the tuts+ site, and to CodeIgniter! I have not ever seen an hour long tutorial for anything, anywhere on the net.

    I recently released an auth system for CodeIgniter. There are a lot of auth libraries in the CI wiki to choose from, but each with little differences.

    If you’re interested in getting a user management and authentication system up and running, you might check out my Community Auth. You don’t have to do it yourself!

    Community Auth website w/ download – http://auth.brianswebdesign.com/

    CI wiki page – http://codeigniter.com/wiki/Community_Auth/

    ( Reply )
  31. PG

    Cody September 11th

    Awesome thank you very much Mr.Way!

    One request: Would it be possible to export your database and include that within the source!

    ( Reply )
  32. PG

    Sri September 11th

    This was a very good tutorial. I like how all the different aspects have been combined in this one (things like templating, sessions, new css properties…)

    Would like to see an extended version of this tutorial for day 7. Preferably a little more robust with things like different access levels.

    Thanks!

    ( Reply )
  33. PG

    Juan C Rois September 11th

    Hey Jeff, for the little research I’ve done so far, I notice that there are “helpers” for Prototype and Scriptaculous. Do you know if there is one for jQuery?
    Also, there should be a link to your screencasts on the CodeIgniter Wiki page. I was going to add them my self but I figured I’d be out of line or maybe it’s better once the series is completed.

    Thanks

    ( Reply )
    1. PG

      Jeffrey Way September 11th

      Yeah – I’m hoping that the CI sites makes some reference to this video series.

      ( Reply )
      1. PG

        Juan C Rois September 15th

        Well, the Wiki page actually allows user edits, so I actually added the links to the screencasts myself.
        This is the link to the CI Wiki page:
        http://codeigniter.com/wiki/Category:Help::Tutorials/

        Hope it brings even more people to Nettus.

  34. PG

    dani September 11th

    Thank you very much Jeffrey. I waited so long for such a tutorial.

    Cheers

    ( Reply )
  35. PG

    Daniel Sitnik September 11th

    Thanks for the awesome tutorial Jeff!!

    And thanks so much for showing an easy way to load header/footer in all pages, I asked for it last week. :D

    ( Reply )
  36. PG

    Fred Flinston September 11th

    This is really cool yeah!!! wohoo

    ( Reply )
  37. PG

    umoor September 11th

    Hey Jeff I see Screencasts are no more hosted on Blip.tv is there a reason for that?

    ( Reply )
  38. PG

    rosnovski September 11th

    Jeff,

    The only thing to say is well done and please keep them coming. Your other series have done us a lot of good. Thanks Muchacho!

    ( Reply )
  39. PG

    C.44 September 11th

    Great Tut again Jeffrey, we won’t get bored by a hourlong screencast. On the contrary, we love hourlong screencasts as it shows your dedication and commitment to make a decent vid that we all benefit from. Props to you :)

    One thing i’ve been wondering, you have the default controller login, after that you have the controller members_area (iirc) that actually checks if the user is_logged_in, but how do we check that in other controllers ? I mean, it wouldn’t be right to just stuff everything into one controller and model with a load of functions and views.

    Btw, are we allowed to give some suggestions for the next tut ? I’d love to see some ajax action to be honest.

    ( Reply )
  40. PG

    Kriesi September 12th

    dont know if I am the only one who is encountering these problems with screencast.com content, but downloading the video doesnt really work. I get decent download speed for the first half and then it drops to 4-5kb/sec until it stops completley. straming the video is a pain as well.

    would love to see this one on itunes, it seems its the only way to get it for me :(

    ( Reply )
  41. PG

    timo.huber September 12th

    thanks again :)

    ( Reply )
  42. PG

    ibura September 12th

    @Kriesi, I am having the same problem with the download link.

    ( Reply )
    1. PG

      Amine September 12th

      Awesome tutorial !! I’ve been waiting for these explanations for so long :)
      Really looking forward for a bullet proof security tutorial and a user management tutorial (groups, rights …) !
      Thanks a lot Jeff for the effort and such complete tutorials !

      ( Reply )
  43. PG

    tom kirby September 12th

    wonderful tutorial,

    it would be good to see a tut on more detailed session security, combinding the CI session DB in aswell,

    also, i noticed you never checked if a username existed before inserting…

    Nice tut! trying to learn CI recently, and this is most defo the best way! many thanks, many more tuts to follow i hope! :)

    ( Reply )
  44. PG

    richard September 12th

    Do you plan on making the sql available for the whole series?

    ( Reply )
  45. PG

    Tyler Perry September 12th

    Very cool tutorial. I have always wanted to learn this stuff. I understand you can only do so much in one video but don’t mind longer videos. Keep it up man. This is extremely helpful when it comes to building websites. This is a skillset that is very important to have.

    Thanks

    ( Reply )
  46. PG

    Tutorial City September 12th

    Great Jeffrey, you’re the man! ;)
    The web comunity owe you a lot!

    ( Reply )
  47. PG

    Vishal September 12th

    Hi Jeff,

    Let me first tell you something that I always wait eagerly to watch your Code Igniter Screencast and I’ve learned Codeigniter with the help of all your 6 videos. I really really appreciate your contribution towards Codeigniter Community. You are doing a lot for beginners like me, I really appreciate that! I would like to thank you a lot for such videos. These videos keeps us updated and boost our confidence to learn something new. I saw that Codeigniter 1.7.2 has been released. Hope you will include some new features from that in your videos. Is it possbile for you to include how to used Ajax/Javascript in Code Igniter?

    Many Thanks
    Vishal

    ( Reply )
  48. PG

    Ryan September 12th

    Though I was able to figure most of this out on my own previously, I’ve still been waiting on this exact tutorial. Good lookin out!

    ( Reply )
  49. PG

    slatron September 12th

    Yeah, I just did this for a number of sites over the past few months in CI – but it’s great to see how someone else goes through the same process. No matter what you’re covering – I always pick up little ways to improve my code. And not always in ways directly pertaining to the subject you’re covering.

    I’ve been recommending CI to a lot of people – and this is the first place I send them for tutorials. Much better than the ones on the CI site.

    Thanks again, Jeffrey! Let’s see some url rewriting in future parts of the series. But really, I’ll watch these tutorials on any CI aspect.

    ( Reply )
    1. PG

      Vishal September 12th

      I do the same thing, I always recommend all PHP/Codeigniter users to watch these videos :-) Thanks again Jeff

      ( Reply )
  50. PG

    Karl Fredrik September 12th

    Hello jeff, really great tutorial – as always :D

    But i get a Database Error :S
    http://i26.tinypic.com/2cclzer.png

    Whats wrong ?

    ( Reply )
    1. PG

      Vishal September 15th

      check your database fields! does it says email_address ? is it spelled correctly in your DB table?

      ( Reply )
  51. PG

    Alexandr September 13th

    Really cool, thx

    ( Reply )
  52. PG

    Moyo September 13th

    Hey Jeff thanks for everything.

    Im having some problems.

    I decided to create a permission denied view, as per your advice “not to echo from a controller”

    as follows
    if(!isset($is_logged_in) || $is_logged_in != true)
    {
    $bata['main_content'] = ‘permission_denied’;
    $this->load->view(’includes/template’, $bata);

    }
    the problem is after doing this, the permission view loads up, but it still displays the contents of the members area page.

    Please what do i do ?

    ( Reply )
    1. PG

      xNoir September 30th

      I have the same problem, you can resolve it???And dont save the data session

      ( Reply )
    2. PG

      bdid November 16th

      +1.

      Also having this issue.

      Mentioned in the tut that die() is not required, but the members area shows without it. But if die() is used, then the access_denied view won’t show…

      ( Reply )
      1. PG

        bdiddy November 18th

        Got it sorted.

        Rather than loading a specific view. Redirect them to a denied page instead.

        if(!isset($is_logged_in) || $is_logged_in != true)
        {
        redirect(’login/denied’);
        }

        And set up the denied function in the login controller (login.php):
        function denied () {
        $data['main_content'] = ‘denied’;
        $this->load->view(’inc/template’, $data);
        }

        Starting to wrap my head around the brilliance of CodeIgniter.

  53. PG

    kenny u September 13th

    Thank You soo much for this tutorial.
    this helped me in so many ways :)

    great :)

    ( Reply )
  54. PG

    Kyle September 13th

    Great tutorial! Would like to see a CI tut showing how to dynamically create pages like a cms.

    ( Reply )
  55. PG

    Stephen Hamilton September 14th

    This series is insanely great. This code igniter series along with your “php for beginners” series over at theme forest is really helping me beat the learning curve for PHP. Thanks a bunch Jeffrey!

    ( Reply )
  56. PG

    Steve September 14th

    Hi Jeff, awesome series, but do you know why this video and any video since 25/08 aren’t showing in the NETTUTS iTunes video podcast subscription?

    Last video showing is Wordpress for Designers : Day 18?

    Thanks!

    ( Reply )
  57. PG

    Dindane September 14th

    Although i don’t think you should be learning people the logic behind a login/registration, i do think you are a great teacher. (i did not follow this broadcast). I went on my own after lesson 3 and created my own registration and login (with salting). But i could not get that session to work so i used good old $_session in stead.

    I read some request about ajax and Ci, i think this would be a great idea. I made a thickbox with a registrationform and a validation on JS with it but i spent way to much time on it.

    So some more claryfication on that subject would be nice.

    Just want to end with me saying: you are doing a great job !

    ( Reply )
  58. PG

    Hamza Oza September 14th

    Thanks Jeff!

    ( Reply )
  59. PG

    Sergio September 14th

    Quick Question. How do I check if the account already exists. for example two users using the same username can be created twice in the db? That doesn’t sound too good. Im sure its only a few lines of code but can anyone lead me in the right direction?

    ( Reply )
    1. PG

      eques September 15th

      well, you run a query where you search for a userame that equals to e.g.

      $this->input->post(’name’);
      q = // here you do your select query to compare

      IF nothing is found, you go on with the actual registrationquery so you say something like:
      if ($q->num_rows() == 0) {
      // here comes your registrationquery
      }

      Hope this helps

      ( Reply )
  60. PG

    Isabela September 14th

    Nice work Jeff!I’m working on my bachelor thesis and the log in form was the edgy thing for me.Thanks a lot!

    ( Reply )
  61. PG

    Khaled September 15th

    Awesome – i’ve learnt alot on my own the last few months (ever since discovering CI), but this was the exact tutorial i’ve been looking for to just link everything i’ve learnt together…

    once you’ve got your head wrapped around this – give dx_auth a look – it’s really more than enough for just about any site with what it can do in terms of Authentication…

    ( Reply )
  62. PG

    Clint Davis September 15th

    Thankyou Jeff,

    Started using CI for my new projects.
    Looking for your new tutorials each week.

    ( Reply )
  63. PG

    iMatt September 16th

    I must say a very very nice tutorial Jeff! It covers very much basics.. for what I was waiting very excited!

    I was wondering if you could also arrange some tutorials for OOP basics?

    Greetz, Matt from Slovenia

    ( Reply )
  64. PG

    C.44 September 16th

    I have some trouble trying to put the record we pulled from the database when validating login credentials into the cookie/sessiondata.

    In the validate function in the membership model i returned $query instead of true so i’d have something to work with. Then in the validate_credentials function in the login controller i added:

    $result = $query->row_array();

    Now that in itself works and iirc adding the result variable/array to the $data that is later being added to the sessiondata, works also. However the redirect after that doesn’t work anymore. In fact nothing does.

    Also, is there a way to get normal error reporting with CI ? It’s driving me completely mad that i’m completely dependant on CI’s errorreporting which is just not cutting it for me.

    ( Reply )
  65. PG

    C.44 September 16th

    Kinda solved my own problem here. Instead of returning $query in the validate function of membership_model, i first did:

    $q_result = $query->row_array();

    and then returned that.

    After that i could safely use that value in the validate_credentials function to pass it on into the sessiondata. Even the redirect works.

    Anyway, i’d still like to see way to enable normal error reporting.

    ( Reply )
  66. PG

    Guido September 17th

    What do you use to code the CSS and see the changes “on the fly” in FF?

    Thanks for the tutorials and keep rocking!

    ( Reply )
    1. PG

      Jeffrey Way September 17th

      Web Developer Extension for Firefox.

      ( Reply )
      1. PG

        Paul Chater November 2nd

        You can do it with Firebug too :)

  67. PG

    Natrium September 18th

    I’m looking forward to an advanced login-tutorial, with password retrieval, salted md5 (how to do it), check if username is already taken and session management by using the db.

    Keep em coming :-)

    ( Reply )
    1. PG

      Natrium September 20th

      and Ajax with jQuery and JSON also would be nice

      ( Reply )
  68. PG

    yellow_leopard September 18th

    Thanks so much for these videos, Mr. Way. I’ve spent most of my time on this site learning, and figured it would be a good idea to sign up for the plus membership!

    I’m loving it, please keep this series running. One of the earlier comments someone asked if you’d do something with the cart class, and a bit of e-commerce in a future tut — I’d really appreciate it if you would consider doing something with that.

    Thanks again.

    ( Reply )
  69. PG

    Alex Lofaso September 18th

    I am really learning a lot from these tutorials Jeff. Keep up the good work. I can’t wait for the next episode.

    ( Reply )
  70. PG

    Egander September 19th

    Hey There Jeff

    Egander here – I’m a huge fan of the tuts on CI.
    Actually – I dont know wether or not, this is the right place – to put out questions… but trying anyway…

    How do i make ci change betweens languages ex: english/french
    and all the info is loacated on the appriate database …. ???

    Nice if you could post a screencast speciic to this dillema

    In advance – thank you for the amazing work, you’re putting into this site
    Pure inspiration – thanks again…

    ( Reply )
  71. PG

    aslam doctor September 19th

    I liked that, really nice tutorials series. Thanks you very much for providing this.

    I would like to see “Form Validation” & “File Upload” tutorials because I really messed a lot & canceled using Codeigniter in the older version, may be 7-8 months ago. But I hope its lot easier this time.

    Thanks again…

    ( Reply )
  72. PG

    handoyo September 20th

    Thanks a lot for the tutorial series..

    ( Reply )
  73. PG

    eBagy September 21st

    Thank you very much for these awesome tutorials

    ( Reply )
  74. PG

    C.44 September 21st

    Jeffrey, any idea when we can expect this episode and the last one to show up on iTunes ? I’d love to keep these things organized :)

    Any idea what the new tut will bring and when it will be released ? You really encouraged me to use this framework and i’d love to see what else is possible.

    ( Reply )
  75. PG

    jeanv September 22nd

    Hi Jeff, i have to say that you really did a great job, thanks a lot for that. What will be the next step ? Ajax ? Wold be wonderful ! Keep on !

    ( Reply )
  76. PG

    yellow_leopard September 23rd

    Anyone know how to add the view correctly without it displaying the main contents? I’ve got the view loaded but it displays the members area page as well as the “please sign in” error message. Referencing towards the end when he says to create a view instead of echoing inside of the controller.

    ( Reply )
  77. PG

    Roeland September 23rd

    This series is awesome! Please keep it coming. I would also like to see some sort Ajax/Jquery with CI tutorial. Best practice methods on implementing it also..

    ( Reply )
  78. PG

    Ronny September 24th

    Hey Jeffrey, can you show us how to correctly use AJAX operations with for instance jQuery in one of your future CodeIgniter tutorials? :)

    ( Reply )
  79. PG

    Brian September 24th

    Hey Jeffrey, great tut as always. All six tuts about CodeIgniter are great. Can You make one tutorial for OsCommerce like shopping cart?

    ( Reply )
  80. PG

    punchi September 24th

    GRACIAS!!!! Thank you Jeff, awesome tutorials =)

    hope the next tutorial have some jquery, it will be great =D

    ( Reply )
  81. PG

    Samurai Girl September 26th

    Really great tutorial. :) i don’t hope you will read all these comments :) but still :)
    i enjoyed it and even found some moments humorous :) ) you dont needed to worry about the wallpaper. really :D

    You covered quite many things in that single hour. Thanks for the series :)

    ( Reply )
  82. PG

    rookie September 26th

    Thank you very much Jeff! It would be great how to make a site with a header, menu, content and footer. It’s a very used layout in web design. You are doing an incredible job! Thank you so much!

    ( Reply )
  83. PG

    emcgfx September 26th

    Thank you so much for posting my request :D Just what I needed. I already have ideas for the next video. PAGINATION :D

    ( Reply )
  84. PG

    Aditu September 26th

    How about more secure version with db sessions and more secure hashes?
    phpQuery would also be a nice tutorial subject. i think there is enough of jQuery tuts – at least those simple ones.

    ( Reply )
  85. PG

    emcgfx September 26th

    I agree, following tutorial should be more secure version of this. Thank you Jeff.

    ( Reply )
  86. PG

    emcgfx September 26th

    Also, I’ve noticed that every view I now create under site controller, is needs to be for members only. Can we have some kind of more unique way of adding like $is_logged_in to the pages we want to be protected and leave other open to public ? Thanks.

    ( Reply )
  87. PG

    Isaac September 26th

    Jeff,

    I saw this video and it pretty much instantly made me love net.tutsplus.com… I will be watching all your videos.

    ( Reply )
  88. PG

    neo September 27th

    The thing about CI sessions is they do not expire when you close the browser. You have to hack the session files in system to make it work that way… but then it ONLY works when you close the browser. It is on or the other.

    I wish CI would provide a better session management.

    ( Reply )
    1. PG

      punchi September 29th

      I had the same “problem”, as far as I know, CI don’t provide something to manage the “real” sessions (as the user still login, looks like more a cookie than a session), so my solution was use directely $_SESSION (http://cl.php.net/manual/en/function.session-start.php)

      If CI can handle this, it will be great, someone knows?

      ( Reply )
      1. PG

        Phil September 30th

        See my above post – there’s a class to do it using “real” sessions, but called using the same CI functions

  89. PG

    Christos September 28th

    Very helpful tutorial series especially for newbies.

    Are you going to show us something more ‘difficult’ ?

    For instance, automatic form generator based on MySQL tables.

    Does this sound too advanced?

    Thanks and again congratz for your work

    ( Reply )
  90. PG

    James Goodin September 29th

    If anyone is using PHP 5.3+ and getting a message ‘The URI you submitted has disallowed characters.’ then please go to this site for the fix.

    http://davidmichaelthompson.com/2009/09/03/fixed-the-uri-you-submitted-has-disallowed-characters-error-codeigniter/

    Also, if using PHP 5.3+ then I also had to remove the ‘&’ characters from a couple lines of the ci code to stop getting the deprecation errors.

    Peace,
    James

    ( Reply )
  91. PG

    Sunil September 29th

    Great tool and tutotrial !!!

    how do you check for unique username before insert. Is there a shortcut validation rule.

    ( Reply )
    1. PG

      Phil September 30th

      one way is like this:

      Set a validation rule:
      $this->form_validation->set_rules(’uname’, ‘Username’, ‘required|callback_username_chk’);

      to which your function would be:

      function username_chk($str){
      $this->db->select(’username’);
      $sql = $this->db->get(’yourtable’);
      $users = array();
      foreach($sql->result() as $username){
      $users[] = $username->username;
      }
      if(in_array($str, $users)){
      $this->form_validation->set_message(’username_chk’,'Sorry this username has been taken’);
      return false;
      }else{
      return true;
      }
      }

      not perfect, but works! :)

      ( Reply )
      1. PG

        Alex October 19th

        Thanks Phil,

        Just one question. If it works, why did you mention it wasn’t perfect? What are the problems with your solution if any?

      2. PG

        Burak November 2nd

        It loads all the usernames into an array.
        The username search should be done on the database side instead.

  92. PG

    Javed Gardezi September 30th

    Hey!! JW when the new episode is coming it has been long. Please do not put so much gap in the series other old concepts diminishes away…. :)
    Every thing has to revised again..

    There is also suggestion :
    Why not give us some practice stuff or material or exercise for this series so that we can continue on our self.

    ( Reply )
  93. PG

    Carlos Vidal September 30th

    This is more a question than a comment on MVC.

    How do you decide between creating a new controller function and a new controller file?

    thanks Jeff!!

    P.S.
    Wich is the best CodeIgniter forum out there?

    ( Reply )
  94. PG

    shin October 1st

    Suggestion for the next tut:

    Extend this login form with using captcha.

    ( Reply )
  95. PG

    David Rodriguez October 2nd

    All I have to say is sweet. Keep them coming.

    ( Reply )
  96. PG

    Roger Le October 6th

    Jeff this was really good stuff. I’ve learned a lot from your brief tutorial.

    I was curious, I’m developing an App where I”ll need both Public and “member only” pages.

    I was thinking of making a modules and locking down the member only module to require the user to login.

    However, that requires me to use someone else’s HMVC library or Matchbox. I think a login library would be better and I’d load it in the controllers I needed.

    The other solution would be to copy paste the login code in EACH controller but lets not do that.

    What are your suggestions?

    ( Reply )
  97. PG

    Chris Farley October 6th

    Great tutorial. I have a general question about best practices though. Is there any advantage to having the controller call a model method to validate the login credentials rather than creating a custom callback for the form_validation helper?

    I’ve done it the latter way and it seems to work, but I’m interested in other points of view regarding the security and/or transparency of such an approach. I’m afraid that it violates the spirit of the MVC framework by introducing model processing into the controller class.

    If that’s the only problem, is there a way to tell the form_validation helper to use a callback from a model class rather than a controller class?

    ( Reply )
  98. PG

    Jonathan Lambert October 12th

    Am I the only one having issue finding the .sql file to load up for these tutorials? I don’t see anything in the downloads, and I’m not too keen to walk through the tutorial and re-type.

    I’m sure this is simple, but I could use some help. I must be missing something.

    Help appreciated.

    ( Reply )
  99. PG

    Anon October 12th

    This video doesn’t load or download fully.

    ( Reply )
  100. PG

    Boba October 19th

    Great tutorial, i am a complete beginner in CodeIgniter and i am looking forward on more screencast about it.

    BTW shouldn’t you close the forms? (You didn’t put </form> or form_close(); at the end of the forms) :)

    ( Reply )
  101. PG

    yabune October 25th

    I’m not being able to watch the video…
    It just gets blank…
    But I did watch the other tutorials before.

    ( Reply )
    1. PG

      sebastian otto October 29th

      me too, would be very nice if it could fixed

      ( Reply )
  102. PG

    Bhaver October 26th

    Is anyone else having trouble with the video from screencast.com ? is there another source for the screencast? Love the series so far, really interested in this particular piece.

    ( Reply )
  103. PG

    David October 26th

    Sorry but this video is not available any longer…. ?!? is not playing and when I try to download it it tells me that the link is broken..

    ( Reply )
  104. PG

    JT October 28th

    I’m having trouble viewing this as well.

    ( Reply )
    1. PG

      Abdullah Alhoshan October 30th

      me tooo :(

      ( Reply )
  105. PG

    Stan October 29th

    Where can I view this tutorial?
    Thanks!

    ( Reply )
  106. PG

    Pr0v4 October 29th

    I would like have this tutorial too… Is possible have it back?

    ( Reply )
  107. PG

    fob October 30th

    I also would like to see this tutorial

    ( Reply )
  108. PG

    Ersin Demirtas November 1st

    Thank you Jeff it was a great Screencast.

    ( Reply )
  109. PG

    Ricky November 5th

    Good stuff Jeff!

    I have a question – is there an easy way to pass messages from a controller to a view? For example, if the user tries to log in, unsucessfully – how would you display a message on the same login page to say “login unsucessful.. etc”?

    ( Reply )
  110. PG

    Jared November 8th

    Finally getting around to going through all these CI tutorials. There great, keep them coming. It would also be nice if you revisited this section and talked about increased security.

    ( Reply )
  111. PG

    Kevin Naidoo November 17th

    Thank you Jeff , this video series helps allot , just one suggestion for future tutorials – please make the video size smaller, I come from a bandwidth starved country.

    ( Reply )
  112. PG

    Gerardo November 20th

    is Chrome for mac available?? I can see you have it installed!

    ( Reply )
    1. PG

      Jeffrey Way November 20th

      The dev beta is available.

      ( Reply )
  113. PG

    Gerardo November 20th

    is Chrome for mac available?? I can see you have it installed!

    This tutorial is the best so far, AWESOME work, there is something wrong with the player, it stops before it finish, I try to reload, and no luck, im downloading it, to see if it woks better this way.

    GREAT WORK, I have learn so much in the part I see.

    ( Reply )
  1. Arrow
    Gravatar

    Your Name
    November 20th