Tuesday 28 May 2013

Creating Login, Registration and Logout pages

Registration Page :
  • Create a form with all the fields you require. 
  • Verify the form using javascript before sending it to server. 
  • Use method 'POST' to send the data which is better than 'GET' method.
  • Connect to database and store the data in the table created.
Login Page :
  • Create a form with login fields. You can use captcha too
  • Verify the form with javascript to check for blank data submissions.
  • Check whether username and passwords match. 
  • If they match, start the session and use a key (username) to reference the user.
  • Redirect to the home page of the user and get the details of the user using the session_variable (key/username).
Logout Page : 
  • As soon as the user clicks "logout" , kill the session. As soon as you kill the session, the stored key is killed. 


Note :
  • When the user tries to open the login page with out logging in, then check whether the session variable is empty. As the session variable is empty, redirect him to login page.
  • Check the above on every page which appears after login so that they cannot access the data with out logging in.
  • Avoid sql-injection by using mysql_escape_string().

Post your doubts as comments below

1 comment:

  1. Thanks for elaborating, this makes our work easier...

    -Surya

    ReplyDelete