Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 363
0 Users 7 Guests Online
Forum Index » Tutorials » PHP User System - Adding New F
Posted on Monday 7th April 2008 at 11:32 PM
UrbanTwitch
templates/default/images/noavatar.png's Avatar
Senior Member
Ok so Im using DanielXP's User system and adding new fields.

Whenever I updated my profile I get: 0 for website name and nothing for avatar and weburl.
Here is my editprofile.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php session_start(); //allows session ?>
<html><?php echo "<title>Editing profile for $user[username] | sodaDome.com</title>"?>
<head>
<link rel="stylesheet" href="http://sodadome.com/images/CoolWater.css" type="text/css" />
</head>
<body>
<?php
include "config.php";
echo 
"<center>";
//checks see if there logged in
if($logged[id]) 

if(isset(
$_GET['update'])){
//Email
$email addslashes(htmlspecialchars($_POST[email])); 
//Where you are
$location addslashes(htmlspecialchars($_POST[location])); 
//Your Age
$age = (int)addslashes(htmlspecialchars($_POST[age])); 
//Gender
$sex addslashes(htmlspecialchars($_POST[sex])); 
//Sodaplay.com account
$sodaname addslashes(htmlspecialchars($_POST[sodaname]));
//Avatar
$avatar addslashes(htmlspecialchars($_POST[avatar])); 
//MSN
$msn = (int)addslashes(htmlspecialchars($_POST[msn])); 
//AIM
$aim = (int)addslashes(htmlspecialchars($_POST[aim])); 
//WebPage
$sitename addslashes(htmlspecialchars($_POST[sitename])); 
//Site URL
$siteurl addslashes(htmlspecialchars($_POST[siteurl])); 
//Small Biography
$smallbio = (int)addslashes(htmlspecialchars($_POST[smallbio])); 
//Personal Text
$customeheader = (int)addslashes(htmlspecialchars($_POST[customeheader])); 
//Interests
$interests = (int)addslashes(htmlspecialchars($_POST[interests])); 
//checks the sex if its ok
if(($sex == "Male") || ($sex == "Female")){
//updates there profile in the db
$update mysql_query("UPDATE `members` SET `email` = '$email', `sex` = '$sex', `siteurl` = '$siteurl', `customeheader` = '$customeheader',  `avatar` = '$avatar', `interests` = '$interests', `sitename` = '$sitename', `aim` = '$aim', `msn` = '$msn', `sodaname` = '$sodaname', `age` = '$age', `location` = '$location' WHERE `username` = '$logged[username]'");
echo 
"Profile updated!";
}
//if the sex is invalid
else{
echo 
"Invalid sex input!";
}
}else{ 
$getuser mysql_query("SELECT * FROM `members` WHERE `username` = '$logged[username]'");
$user mysql_fetch_array($getuser); 
echo 
"<form name='form1' action='editprofile.php?update' method='post'>
<fieldset style='width: 500'>
<b>Avatar:</b> <input type='text' name='avatar' size='30' value='
$user[avatar]'><br>
<b>Email:</b> <input type='text' name='email' size='30' maxlength='55' value='
$user[email]'><br>
<b>Location:</b> <input type='text' name='location' size='30' maxlength='40' value='
$user[location]'><br>
<b>Age:</b> <input type='text' name='age' size='3' maxlength='3' value='
$user[age]'><br>
<b>Sex:</b> <select size='1' name='sex' value='
$user[sex]'>
<option value='Male' "
; if($user[sex] == Male) { 
echo 
"selected"; } 
echo 
">Male</option> 
<option value='Female' "
; if($user[sex] == Female) { 
echo 
"selected"; } 
echo 
">Female</option>
</select><br>
<B>Site Name:</b> <input type='text' name='siteurl' size='30' maxlength='55' value='
$user[siteurl]'><br>
<B>Site URL:</b> <input type='text' name='webpage' size='30' maxlength='55' value='
$user[webpage]'><br>
<b>sodaplay account:</b> http://sodaplay.com/creators/<input type=text name=sodaname size=20 maxlength=25 onkeydown=change_case(); onBlur=change_case(); value=
$user[sodaname]><br><br>
<input type='submit' value='Update'>
</fieldset></form>"
;
}
}
else
{
echo 
"You are not logged in.";
}
echo 
"<center>";
?>
<script type="text/javascript">
function change_case()
{
document.form1.sodaname.value=document.form1.sodaname.value.toLowerCase();
}
</script>

</body></html>


and here is members.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php session_start(); //allows session ?>
<html><?php echo "<title>Member List | sodaDome.com</title>"?>
<head>
<link rel="stylesheet" href="http://sodadome.com/images/CoolWaterTable.css" type="text/css" />
</head>
<body>
<?php
include "config.php";
echo 
"<center>";
if(isset(
$_GET['user'])){ //if there trying to view a profile
//gets the user name and makes it safe
$username addslashes($_GET[user]);
//querys the db to find the username
$getuser mysql_query("SELECT * FROM `members` WHERE `username` = '$username'");
//checks see if the username exists in the db 

$usernum mysql_num_rows($getuser);
//if it don't exist 
if ($usernum == 0


//don't exist

echo ("User Not Found"); 


//if it does exist then show there profile
else
{
$user mysql_fetch_array($getuser); 
echo 
"<fieldset style='width: 500'>
<b>
$user[username]'s Profile | sodaDome.com</b><br><br>
<img src=
$user[avatar] width=150px height=150px border=0><br><br>
Last Seen: 
$user[last_seen]<br>
<a href='friendrequest.php?user=
$user[username]'>Add as Friend</a><br>

Email: 
$user[email]<br>
Member No.: 
$user[id]<br>
Website: <a href=
$user[siteurl] target=_blank>$user[sitename]</a><br>
Location: 
$user[location]<br>
Sex: 
$user[sex]<br>
Age: 
$user[age]<br>
sodaplay account: <a href=http://sodaplay.com/creators/
$user[sodaname] target=_blank>$user[sodaname]</a>
</fieldset>"
;

}
}
else
{
//gets all the members from the database
$getusers mysql_query("SELECT * FROM `members` ORDER BY `id` ASC") or die(mysql_error()); 
//loops there name out
while ($user mysql_fetch_array($getusers)) 

echo 
"<a href='members.php?user=$user[username]'>$user[username]</a><br>"
}
}
echo 
"<center>";
?> 

</body></html>


and my myphpadmin seems fine. But just incase- can ya give me the text to add them to the DB? Like ADD `avatar` VARCHAR( 255 ) NOT NULL default 'http://img91.imageshack.us/img91/5952/noavvysi4.png';? Right? I don't know.
Posted on Monday 9th June 2008 at 03:28 AM
Adam981
templates/default/images/noavatar.png's Avatar
Junior Member
http://rmb-scripting.com/tutorials.php?tutorial&tid=111