I needed to know how one would go about setting up a default avatar image for a user upon registration and allow the user to upload one of their own later. Like in facebook.
My user table fields(shortened):
user_id, first_name, last_name, username, tel_no etc.
My pictures table:
Pic_id, pic_large_url, pic_thumb_url, user_id, avatar, timestamp
I need to know what kind of php code I need to be able to accomplish this. Do I put my default_avatar.png image in a folder and reference it in the pictures table and where do I go from there?
I wanted to use an avatar (bit) field 1 if it is a user’s avatar, 0 if it is not.
I also have an updates table that allows users to upload text and images in their updates or just text only as follows:
avatar pic – update text – update image(if image)
avatar pic – update text – default image(if update image not uploaded)
default avatar pic – update text – default image(if update image not uploaded)
I guessing if i find out how to put a default avatar, ill find out how to do the above.
I will appreciate any help out there.
In your
avatardatabase field, either setup the default to point towards your default avatar, or you can check if itsnull.If it is null, render the default avatar image 🙂