+ Reply to Thread
Results 1 to 3 of 3

Thread: how to create a login system

  1. #1
    mactrac11's Avatar
    mactrac11 is offline x10Hosting Member mactrac11 is an unknown quantity at this point
    Join Date
    Oct 2009
    Posts
    24

    how to create a login system

    how do i create a login system for my website i was wanting to test it out (i am just testing things so i cant get a better thought on this stuff) can you guys help me out?
    Please Rate my answer Click the THANKS *Note: My website is a personal TEST site since i am a lil new with coding, (everyone starts somewhere)*

  2. #2
    smithee's Avatar
    smithee is offline x10Hosting Member smithee is an unknown quantity at this point
    Join Date
    Aug 2009
    Location
    NIMBY
    Posts
    45

    Re: how to create a login system

    Hi mactrac11, I'm currently creating my own login scripts on behalf of someone else's site (although slowly, as I'm basing it in classes as much as possible!). A while ago, I taught myself on how to achieve this by coming across "PHP for Beginners by a Beginner: Simple Login, Logout, and Session Handling" on Dev Articles. It's quite an old post, but it does explain about the three most important requirements to a successful login (and logout) system... the login page with the form, the method of storing login details, and session implementation. Without these, you wouldn't get far!! It also explains about how to check if the user has entered the correct details, and detecting when the user wants to log out.

    A few things I would suggest though:
    1. It makes use of the "session_register" function; this has now been deprecated, so using it is not advised. Instead, use $_SESSION and assign a value to it.
    2. It also makes use of the "session_is_registered" function; again, this has now been deprecated. So instead of using:
      if(session_is_registered('username')), use:
      if(isset($_SESSION['username'])).
    3. It makes use of the built-in mysql functions. These aren't deprecated, and are still used massively. However in terms of robustness and security, there are other database object handlers out there that does a much better job at preventing SQL Injections from occuring. A good alternative is the PDO handler. The page "Writing MySQL Scripts with PHP and PDO" shows a good tutorial on this, and it's what I've referred to to get me off the ground with PDO.

    So whilst looking through that page (or any other you come across), please be aware of the points I have mentioned
    .

    Be nice to nerds. Chances are you’ll end up working for one. - Bill Gates

  3. #3
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: how to create a login system

    • The article also doesn't use a strong enough password hashing scheme. MD5 is considered broken, and the scheme doesn't use any salt. Read "Enough With The Rainbow Tables: What You Need To Know About Secure Password Schemes" and "Password Hashing".
    • The sample system is vulnerable to session hijacking. There's no foolproof way of preventing it, since there's no unforgeable, unique data coming from a user. The best you can do is check that the remote IP stays the same; if it doesn't, generate a new session ID with session_regenerate_id and force the user to login again.
    • You should use session_regenerate_id when a user successfully logs in to prevent session fixation.
    • Instead of session_unset, scripts using $_SESSION should clear out session data by setting $_SESSION to an empty array.
      PHP Code:
      $_SESSION = array(); 
    • The username column should be made UNIQUE.

    There are a few things about the article that don't matter too much.
    • The article loops over query results when there's only a single result.
      PHP Code:
      $rowCheck mysql_num_rows($result); 
      if(
      $rowCheck 0){ 
          while(
      $row mysql_fetch_array($result)){ 
      While not functionally incorrect, it's unnecessary and is counter to self-documenting code practices, impacting readability.
    • If there is at most 1 result row, a LIMIT 1 clause in a query can produce a more efficient query execution plan. If you're querying against a UNIQUE column, the query optimizer will probably produce the same plan without a LIMIT clause, though including the clause won't hurt and is a hint to a programmer that the query should produce at most one result (more self-documenting code).
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Login System
    By nitin94 in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 10-14-2009, 05:02 PM
  2. 550 Can't create directory: Read-only file system
    By buying in forum Free Hosting
    Replies: 6
    Last Post: 10-08-2009, 09:19 AM
  3. Create own members system
    By Dhryn in forum Free Hosting
    Replies: 2
    Last Post: 05-01-2008, 06:49 AM
  4. php login system help...
    By Agenator in forum Programming Help
    Replies: 7
    Last Post: 04-13-2008, 08:43 AM
  5. login system help
    By brentcatoe in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 10-04-2005, 04:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers