Thursday, 6 March 2014

Logging In and Out

I have already sorted out some of the login process within my project but I needed to finish of various sections for it to function. I created another table within the database called login here the users login details will be stored so that the system recognises them. 


Now that i had implemented usernames and passwords to the existing users within the database I decided to enable the session start on all the website pages. I also change the number of the rows to 0 now that i was going to test the functionality. 

Unfortunately the session has an error at this moment it does not seem to be able to identify the name of the field within the database. To try and solve this I change the userid name to usersid that is found on the login table but unfortunately it still does not seem to work. Since I need to carry out user-testing soon I decided that I would comment out the session and test the login manually. 


Within the login field I typed the username and password I had allocated for user 1 if the details match those within the database it would redirect the user to another page where a home button would be displayed. This button enabled them to direct to the homepage and use the website. After testing this function I removed the link to another page and made the code redirect to the same page in order for the user to be able to continue on what they would like to do. 


Within the PHP code I wrote a section that identifies the user when they log in and provides them with various actions. At this point I added a link to heir user profile and a log out function for when they have finished using the system. As you can see below the system has identified the user and displayed their username on the screen, it has also provided them with the links I mentioned previously. 



If the information does not match an error message will appear instead of the username and links to other pages. 



For security reasons it is important that I enable users to log out of the system once they finished using it. To be able to log in I included a session start for the users therefore the log out process will need to destroy this session. Below I have provided the code for this function instead of creating a new page with a message informing the user that they have logged out I decided to redirect them to the index page where they will be able to log in again. This logout session destroys the existing one already created beforehand therefore preventing others from using it. 


Sources
Stackoverflow.com. 2011. php - Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in - Stack Overflow. [online] Available at: http://stackoverflow.com/questions/5473981/warning-mysql-fetch-array-expects-parameter-1-to-be-resource-boolean-given-i [Accessed: 5 Mar 2014].

No comments:

Post a Comment