Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 433
0 Users 6 Guests Online
Forum Index » PHP + MySQL » anyone hlep me with this code?
Posted on Saturday 30th August 2008 at 08:06 PM
peza
templates/default/images/noavatar.png's Avatar
Newbie
I am trying to create a user profiles and this si my first, i have created the page that lets you view them it all works, but i am stuck on the edit profile page it wont send to the db and change it. Im only trying to get nationality to work at the momment but i have tried with all the php coding for them all. Im not sure wether its a basic thing as my php knowledge isn't great.

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
88
89
90
91
92
93
94
<?

session_start
();
include 
"../includes/config.php";
include 
"../includes/functions.php";
logincheck();

$username=$_SESSION['username'];
$fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));

if (
strip_tags($_POST['Submit']) && strip_tags($_POST['nationality']) && strip_tags($_POST['location']) && strip_tags($_POST['age']) && strip_tags($_POST['website']) && strip_tags($_POST['gender']) && strip_tags($_POST['msn']) && strip_tags($_POST['aim']) && strip_tags($_POST['steam']) && strip_tags($_POST['xfire']) && strip_tags($_POST['email']) && strip_tags($_POST['favdj']) && strip_tags($_POST['favplayer']) && strip_tags($_POST['favweapon']) && strip_tags($_POST['qoute']) && strip_tags($_POST['extra']) && strip_tags($_POST['favmap'])){

$editprofile mysql_query("UPDATE users SET nationality='$nationality', location='$location', age='$age', website='$website', gender='$gender', msn='$msn', aim='$aim', steam='$steam', xfire='$xfire', favweapon='$favweapon', favplayer='$favplayer', favdj='$favdj', favmap='$favmap', quote='$quote', WHERE username='$username'");

echo 
"Your proflie has been updated";
echo 
"<meta http-equiv=\"refresh\" content=\"0;URL=editprofile.php\">";

}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Edit Profile</title>
<link href="epro.css" rel="stylesheet" type="text/css" />
</head>
<style type="text/css">
.epro {
    font-family: verdana;
    font-size: 12px;
    font-style: normal;
}
</style>
<body>
<form name="form1" method="post" action="">
<div class="epro" id="epro">
  <table width="600" border="1" align="center">
    <tr>
      <td colspan="2" align="center"><strong>Edit Profile</strong></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><a href="changepw.php">Change Password </a></td>
    </tr>
    <tr>
      <td colspan="2" align="center">Personal Information </td>
    </tr>
    <tr>
      <td width="300">Nationality:
         <input name="nationality" id="nationality" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->nationality"?>" /></td>
      <td width="284">Age:
        <input type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" name="username" /></td>
    </tr>
    <tr>
      <td>Location:
        <input type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" name="username" /></td>
      <td>Website:
        <input type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" name="username" /></td>
    </tr>
    <tr>
      <td>Gender:
        <input type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" name="username" /></td>
      <td>Email:
        <input type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" name="username" /></td>
    </tr>
    <tr>
      <td colspan="2" align="center">Contact</td>
    </tr>
    <tr>
      <td>MSN:
        <input type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" name="username" /></td>
      <td>Steam:
        <input type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" name="username" /></td>
    </tr>
    <tr>
      <td>AIM:
        <input type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" name="username" /></td>
      <td>Xfire:
        <input type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" name="username" /></td>
    </tr>
    <tr>
      <td><input type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" name="username" /></td>
      <td><input type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" name="username" /></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input name="submit" type="submit" id="submit" value="Submit"></td>
    </tr>
  </table>
</div>
</form>
</body>
</html>


anyone see what wrong?
Posted on Sunday 31st August 2008 at 12:43 AM
Vic Vance
templates/default/images/noavatar.png's Avatar
Active Member
Urrm I think

name="form1"

should be

name="form"
Posted on Sunday 31st August 2008 at 04:10 PM
peza
templates/default/images/noavatar.png's Avatar
Newbie
hmm ive tried that nothing still happens
Posted on Sunday 31st August 2008 at 06:26 PM
peza
templates/default/images/noavatar.png's Avatar
Newbie
i now have this thiknig it might work now but still no luck =[

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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?

session_start
();
include 
"../includes/config.php";
include 
"../includes/functions.php";
logincheck();

$username=$_SESSION['username'];
$fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));

if (
strip_tags($_POST['submit']) && strip_tags($_POST['nationality']) && strip_tags($_POST['location']) && strip_tags($_POST['age']) && strip_tags($_POST['website']) && strip_tags($_POST['gender']) && strip_tags($_POST['msn']) && strip_tags($_POST['aim']) && strip_tags($_POST['steam']) && strip_tags($_POST['xfire']) && strip_tags($_POST['email']) && strip_tags($_POST['favdj']) && strip_tags($_POST['favplayer']) && strip_tags($_POST['favweapon']) && strip_tags($_POST['quote']) && strip_tags($_POST['extra']) && strip_tags($_POST['gender']) && strip_tags($_POST['favmap'])){
$nationality=strip_tags($_POST['nationality']);
$location=strip_tags($_POST['location']);
$age=strip_tags($_POST['age']);
$website=strip_tags($_POST['website']);
$age=strip_tags($_POST['age']);
$gender=strip_tags($_POST['gender']);
$msn=strip_tags($_POST['msn']);
$aim=strip_tags($_POST['aim']);
$steam=strip_tags($_POST['steam']);
$xfire=strip_tags($_POST['xfire']);
$email=strip_tags($_POST['email']);
$favdj=strip_tags($_POST['favdj']);
$favplayer=strip_tags($_POST['favplayer']);
$favweapon=strip_tags($_POST['favweapon']);
$quote=strip_tags($_POST['quote']);
$extra=strip_tags($_POST['extra']);
$favmap=strip_tags($_POST['favmap']);

mysql_query("UPDATE users SET nationality='$nationality', location='$location', gender='$gender', website='$website', age='$age', msn='$msn', aim='$aim', steam='$steam', xfire='$xfire', favweapon='$favweapon', favplayer='$favplayer', favdj='$favdj', favmap='$favmap', quote='$quote', WHERE username='$username'");

echo 
"Your proflie has been updated";
echo 
"<meta http-equiv=\"refresh\" content=\"0;URL=editprofile.php\">";
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Edit Profile</title>
<link href="epro.css" rel="stylesheet" type="text/css" />
</head>
<style type="text/css">
.epro {
    font-family: verdana;
    font-size: 12px;
    font-style: normal;
}
</style>
<body>
<form name="form" method="post" action="">
<div class="epro" id="epro">
  <table width="600" border="1" align="center">
    <tr>
      <td colspan="2" align="center"><strong>Edit Profile</strong></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><a href="changepw.php">Change Password </a></td>
    </tr>
    <tr>
      <td colspan="2" align="center">Personal Information </td>
    </tr>
    <tr>
      <td width="300">Nationality:
         <input name="nationality" id="nationality" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->nationality"?>" /></td>
      <td width="284">Age:
        <input name="age" id="age" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->age"?>" /></td>
    </tr>
    <tr>
      <td>Location:
        <input name="location" id="location" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->location"?>" /></td>
      <td>Website:
        <input name="website" id="website" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->website"?>" /></td>
    </tr>
    <tr>
      <td>Gender:
<select size='1' name='gender' value='gender'>
<option value="male">Male</option> 
<option value="female">Female</option>
</select>
        </td>
      <td>Email:
        <input name="email" id="email" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->email"?>" /></td>
    </tr>
    <tr>
      <td colspan="2" align="center">Contact</td>
    </tr>
    <tr>
      <td>MSN:
        <input name="msn" id="msn" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->msn"?>" /></td>
      <td>Steam:
        <input name="steam" id="steam" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->steam"?>" /></td>
    </tr>
    <tr>
      <td>AIM:
        <input name="aim" id="aim" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->aim"?>" /></td>
      <td>Xfire:
        <input name="xfire" id="xfire" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->xfire"?>" /></td>
    </tr>
    <tr>
      <td colspan="2" align="center">Other</td>
    </tr>
    <tr>
      <td>Favourite DJ:
        <input name="favdj" id="favdj" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->favdj"?>" /></td>
      <td>Favourite Weapon:
        <input name="favweapon" id="favweapon" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->favweapon"?>" /></td>
    </tr>
    <tr>
      <td>Favourite Player:
        <input name="favplayer" id="favplayer" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->favplayer"?>" />
        </td>
      <td>Favourite Map:
        <input name="favmap" id="favmap" type="favmap" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->favmap"?>" /></td>
    </tr>
    <tr>
      <td>Quote:
      <input name="quote" id="quote" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="&quot;<?php echo "$fetch->quote"?>&quot;" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td height="18" colspan="2" align="center">Extra</td>
    </tr>
    <tr>
      <td colspan="2">
      <label></label>
      <textarea name="textarea" cols="96" rows="10"><?php echo "$fetch->extra"?></textarea></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input name="submit" type="submit" id="submit" value="Submit"></td>
    </tr>
  </table>
</div>
</form>
</body>
</html>
Posted on Sunday 31st August 2008 at 07:28 PM
Vic Vance
templates/default/images/noavatar.png's Avatar
Active Member
Are you meant to have that text &quot; at the bottom where it says
&quot;"
Posted on Sunday 31st August 2008 at 10:53 PM
peza
templates/default/images/noavatar.png's Avatar
Newbie
yes i think its for the users quote and u cant put " next to one in the html so its &quot;"
Posted on Sunday 31st August 2008 at 11:51 PM
ShadowMage
templates/default/images/noavatar.png's Avatar
Senior Member
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<? 
session_start
(); 
include 
"../includes/config.php"
include 
"../includes/functions.php"
logincheck(); 

$username=$_SESSION['username']; 
$fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'")); 

if (
$_POST['IHAZBEENSUBMITTED']){ 
$nationality=strip_tags($_POST['nationality']); 
$location=strip_tags($_POST['location']); 
$age=strip_tags($_POST['age']); 
$website=strip_tags($_POST['website']); 
$age=strip_tags($_POST['age']); 
$gender=strip_tags($_POST['gender']); 
$msn=strip_tags($_POST['msn']); 
$aim=strip_tags($_POST['aim']); 
$steam=strip_tags($_POST['steam']); 
$xfire=strip_tags($_POST['xfire']); 
$email=strip_tags($_POST['email']); 
$favdj=strip_tags($_POST['favdj']); 
$favplayer=strip_tags($_POST['favplayer']); 
$favweapon=strip_tags($_POST['favweapon']); 
$quote=strip_tags($_POST['quote']); 
$extra=strip_tags($_POST['extra']); 
$favmap=strip_tags($_POST['favmap']); 

mysql_query("UPDATE users SET nationality='$nationality', location='$location', gender='$gender', website='$website', age='$age', msn='$msn', aim='$aim', steam='$steam', xfire='$xfire', favweapon='$favweapon', favplayer='$favplayer', favdj='$favdj', favmap='$favmap', quote='$quote', WHERE username='$username'") or die(mysql_error()); 

echo 
"Your proflie has been updated"
echo 
"<meta http-equiv=\"refresh\" content=\"0;URL=editprofile.php\">"


?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<title>Edit Profile</title> 
<link href="epro.css" rel="stylesheet" type="text/css" /> 
</head> 
<style type="text/css"> 
.epro { 
    font-family: verdana; 
    font-size: 12px; 
    font-style: normal; 

</style> 
<body> 
<form name="form" method="post" action=""> 
<div class="epro" id="epro"> 
  <table width="600" border="1" align="center"> 
    <tr> 
      <td colspan="2" align="center"><strong>Edit Profile</strong></td> 
    </tr> 
    <tr> 
      <td colspan="2" align="center"><a href="changepw.php">Change Password </a></td> 
    </tr> 
    <tr> 
      <td colspan="2" align="center">Personal Information </td> 
    </tr> 
    <tr> 
      <td width="300">Nationality: 
         <input name="nationality" id="nationality" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->nationality"?>" /></td> 
      <td width="284">Age: 
        <input name="age" id="age" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->age"?>" /></td> 
    </tr> 
    <tr> 
      <td>Location: 
        <input name="location" id="location" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->location"?>" /></td> 
      <td>Website: 
        <input name="website" id="website" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->website"?>" /></td> 
    </tr> 
    <tr> 
      <td>Gender: 
<select size='1' name='gender' value='gender'> 
<option value="male">Male</option>  
<option value="female">Female</option> 
</select> 
        </td> 
      <td>Email: 
        <input name="email" id="email" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->email"?>" /></td> 
    </tr> 
    <tr> 
      <td colspan="2" align="center">Contact</td> 
    </tr> 
    <tr> 
      <td>MSN: 
        <input name="msn" id="msn" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->msn"?>" /></td> 
      <td>Steam: 
        <input name="steam" id="steam" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->steam"?>" /></td> 
    </tr> 
    <tr> 
      <td>AIM: 
        <input name="aim" id="aim" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->aim"?>" /></td> 
      <td>Xfire: 
        <input name="xfire" id="xfire" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->xfire"?>" /></td> 
    </tr> 
    <tr> 
      <td colspan="2" align="center">Other</td> 
    </tr> 
    <tr> 
      <td>Favourite DJ: 
        <input name="favdj" id="favdj" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->favdj"?>" /></td> 
      <td>Favourite Weapon: 
        <input name="favweapon" id="favweapon" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->favweapon"?>" /></td> 
    </tr> 
    <tr> 
      <td>Favourite Player: 
        <input name="favplayer" id="favplayer" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->favplayer"?>" /> 
        </td> 
      <td>Favourite Map: 
        <input name="favmap" id="favmap" type="favmap" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="<?php echo "$fetch->favmap"?>" /></td> 
    </tr> 
    <tr> 
      <td>Quote: 
      <input name="quote" id="quote" type="text" style="background-color:#FFFFFF; border:1px solid #000000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;" value="&quot;<?php echo "$fetch->quote"?>&quot;" /></td> 
      <td>&nbsp;</td> 
    </tr> 
    <tr> 
      <td height="18" colspan="2" align="center">Extra</td> 
    </tr> 
    <tr> 
      <td colspan="2"> 
      <label></label> 
      <textarea name="textarea" cols="96" rows="10"><?php echo "$fetch->extra"?></textarea></td> 
    </tr> 
    <tr> 
      <td colspan="2" align="center"><input name="IHAZBEENSUBMITTED" type="submit" id="submit" value="Submit"></td> 
    </tr> 
  </table> 
</div> 
</form> 
</body> 
</html>

Try That
Posted on Monday 1st September 2008 at 12:09 AM
peza
templates/default/images/noavatar.png's Avatar
Newbie
thanks