Forum Moderators: open
ID – an auto-incrementing numerical ID which references each user. It is the primary key of the table, and automatically increases by 1 for each user. So the first user will have ID 1, the second user, ID 2, and so on.
username VARCHAR(255) – the user’ username
password VARCHAR(255) – the user’s password
interests VARCHAR(255) – the user’s interests
birthday VARCHAR(255) - the user’s birthday in a format like “June 6 1970”
If Im right with what I think I need to do I have created an index page, sign-up page(html and a php script) and a login page (html and a php script).
Then Ive got to do part b but dont have a clue how to go about doing it which is the following:
Write a profile page. This should display the name, interests, birthday and friends of the currently logged in user. Ideally profiles should only be visible to friends of this user, but this is not necessary for a basic pass.
You will need to use the friends table to work out who are the friends of the currently logged-in user. This is also set up on Edward and has the following structure:
ID – an auto-incrementing numerical ID which references each record. It is the primary key of the table, and automatically increases by 1 for each record. So the first record will have ID 1, the second record, ID 2, and so on.
me – the current user
friend – friends of the current user
This is probably best illustrated by example. Imagine the user with username John has three friends: Amar, Jeremy, and Scott. Scott, meanwhile, has as friends Amar, Jeremy and Jamie. In other words, John has made Scott his friend, but Scott has not yet made John his friend, and therefore Scott can view John’s profile but John cannot yet view Scott’s profile (because Scott has not agreed to John becoming his friend yet). The table would look like the following:
IDmefriend
1JohnAmar
2JohnJeremy
3JohnScott
4ScottAmar
5ScottJeremy
6ScottJamie
Anyone able to help me please as need to do it tonight and have 2 other parts to do.
First off, do you really want to give the user the ability to have a 255 character username? I'd limit that to about 25. You don't need a username like "gee-I-guess-Ill-make-a-username-as-long-as-I-want-and-have-the-string-run-off-the-page".
Secondly, 255 chars is way too many for a password field. Are you planning on storing a plaintext password? Bad idea for any sort of "real" login application. I'd suggest using CHAR(40) and SHA1 to run the user's password through a one way hash function, storing the SHA1's output hex string in the password field. Each time the user logs in, compare the hash of the entered password with the one stored in the database.
A date field (such as a birthday) should be a DATE type field. Never store a date in a char type column, you'll wish you hadn't when you want to start performing any sort of math with the date data.
I think these are good tips to carry with you through whatever application you're building.
[edited by: coopster at 12:15 am (utc) on Feb. 27, 2009]
[edit reason] removed reference to a duplicate thread that was removed [/edit]