User Profile Avatar

Got an idea for a tutorial ? Share it here.
Post Reply
User avatar
kalipsso
Posts: 30
Joined: Thu Jun 09, 2011 3:03 pm
Location: Bucharest
Contact:

User Profile Avatar

Post by kalipsso »

I was wondering if you can make a tutorial on how to add a user profile picture/avatar...or a gallery for users from which they can pick the profile avatar/picture...that will be interesting...
thank you and regards.
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: User Profile Avatar

Post by bowersbros »

Its fairly simple.

You probably know how to upload an image (im sure jacek has covered this) And im sure you know how to insert data into a database, and how to fetch data and how to echo out data.

You have everything you need there.

When you upload the image, make sure you upload it to a certain location where they are all stored, and make sure the file name is unique (good technique for this is often just the timestamp, however for popular websites, adding a salt and md5ing it will make it completely unique.

This data you then store into the database alongside the user profile data (in the same row as the person it corresponds to. For the image you store the location on the server from root. Eg. /profile/images/image0123133131.jpg

When you fetch that data on the persons profile page (eg, by using $_GET on the ID field and then fetching all the data you need from the row matching that ID. you get the location of the image, which you then echo out into a <img src="" /> tag.

There you have it.

User Profile Avatars
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
User avatar
kalipsso
Posts: 30
Joined: Thu Jun 09, 2011 3:03 pm
Location: Bucharest
Contact:

Re: User Profile Avatar

Post by kalipsso »

bowersbros wrote:Its fairly simple.

You probably know how to upload an image (im sure jacek has covered this) And im sure you know how to insert data into a database, and how to fetch data and how to echo out data.

You have everything you need there.

When you upload the image, make sure you upload it to a certain location where they are all stored, and make sure the file name is unique (good technique for this is often just the timestamp, however for popular websites, adding a salt and md5ing it will make it completely unique.

This data you then store into the database alongside the user profile data (in the same row as the person it corresponds to. For the image you store the location on the server from root. Eg. /profile/images/image0123133131.jpg

When you fetch that data on the persons profile page (eg, by using $_GET on the ID field and then fetching all the data you need from the row matching that ID. you get the location of the image, which you then echo out into a <img src="" /> tag.

There you have it.

User Profile Avatars

Yes...but i was thinking on a user gallery, and the option for the user to select from that gallery the profile picture.( Select picture as profile pic)...that's not the same as uploading a user profile image...and not everyone knows how to do it, that's why it will be a good and useful tutorial..
Regards.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: User Profile Avatar

Post by jacek »

bowersbros wrote:adding a salt and md5ing it will make it completely unique.

That wont actually add any more uniqueness. What you are doing to the timestamp is always the same, so the resulting value is still only dependant on the input.

Also, I will add this to the list ;)
Image
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: User Profile Avatar

Post by bowersbros »

jacek wrote:
bowersbros wrote:adding a salt and md5ing it will make it completely unique.

That wont actually add any more uniqueness. What you are doing to the timestamp is always the same, so the resulting value is still only dependant on the input.

Also, I will add this to the list ;)


Where i said salt, i meant random string ;D
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Post Reply