Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 496
0 Users 6 Guests Online
Forum Index » PHP + MySQL » Avatar Customization in RMB Us
Posted on Thursday 7th June 2007 at 02:50 PM
MCP
templates/default/images/noavatar.png's Avatar
Junior Member
Could someone help me setup an avatar capability on my site.
For example.

Thanks.
Posted on Thursday 7th June 2007 at 08:55 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
Call it avatar.php
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
include "config.php";
if(
$logged[username])
{
switch(
$_GET[page])
{
default:
echo (
"

<form action='?page=upload' enctype='multipart/form-data' method='POST'>
<table border='1'>
<tr>
<td>Avatar</font></td>
<td><input type='file' size='7' name='avatar' id='avatar'></td>
</tr>
<tr>
<td colspan='2' align='center'><input type='submit' name='submit' value='Upload'></td>
</tr>
</table>
</form>
"
);
break;

case 
'upload':
$filename $_FILES["avatar"]["name"];
$tmp_name $_FILES["avatar"]["tmp_name"];
$avatar "images/$filename";
$username $logged[username];
if (
move_uploaded_file($tmp_name"images/".$filename))
{
$query mysql_query("UPDATE `members` SET `avatar` = '$avatar' WHERE `username` = '$logged[username]'");
echo (
"File uploaded $avatar");
}
else
{
die(
"Uploading file Failed");
}
break;
}
}
?>


Just add an avatar row in your PHPmyAdmin, avatar,VARCAHR,225 thats it.

Must also create a folder called images where avatar.php is located. can CHMOD it to 777

Works its tested
Posted on Friday 8th June 2007 at 02:32 AM
MCP
templates/default/images/noavatar.png's Avatar
Junior Member
It works. Thanks a bunch. I taught myself to make the avatar appear. Easy.
Posted on Friday 8th June 2007 at 05:06 AM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
<img src='$logged[avatar]'> ?
Posted on Friday 8th June 2007 at 06:55 AM
MCP
templates/default/images/noavatar.png's Avatar
Junior Member
Yup. I also have it linking to the profile.
Posted on Friday 8th June 2007 at 06:57 AM
MCP
templates/default/images/noavatar.png's Avatar
Junior Member
Actually it is
PHP Code
1
<a href='members.php?user=$user[username]'><img src='$user[avatar]'></a>
Posted on Friday 8th June 2007 at 10:31 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
mhm great stuff basic html
Posted on Friday 22nd June 2007 at 11:15 PM
dtnet
templates/default/images/noavatar.png's Avatar
Active Member
What is the code for that if the users don't have uploaded their own avatar, there is a temporary avatar-picture in the profiles?
Posted on Friday 22nd June 2007 at 11:30 PM
dtnet
templates/default/images/noavatar.png's Avatar
Active Member
http://henrik.hotserv.dk/members.php?user=Kristina
http://henrik.hotserv.dk/members.php?user=Mads

As you can see it is two different users, with the same profile. That appeared when I used this code you gave me.

http://norskwebforum.no/pastebin/8955
Posted on Saturday 14th July 2007 at 07:53 PM
dtnet
templates/default/images/noavatar.png's Avatar
Active Member
?