Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 413
0 Users 21 Guests Online
Forum Index » PHP + MySQL » Editprofile Doesn't update
Posted on Tuesday 25th March 2008 at 10:24 AM
Dalez
templates/default/images/noavatar.png's Avatar
Junior Member
When i try to update Editprofile, it says it has updated, but it actaully hasn't. And i don't know why.

Heres my code:

<html>
<head>
<link href="../style/style1.css" rel="stylesheet" type="text/css" />
</head>
</html>
<?php
session_start(); //allows session
include "config.php";
echo "<center>";
//checks see if there logged in
if($logged[id]) {
if(isset($_GET['update'])) {
$email = addslashes(htmlspecialchars($_POST[email]));
$sig = addslashes(htmlspecialchars($_POST[sig]));
$title = addslashes(htmlspecialchars($_POST[title]));
$location = addslashes(htmlspecialchars($_POST[location]));
$age = (int)addslashes(htmlspecialchars($_POST[age]));
$sex = addslashes(htmlspecialchars($_POST[sex]));
//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', `title` = '$title', `sex` = '$sex', `age` = '$age', `location` = '$location', 'sig' = '$sig' 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 action='editprofile.php?update' method='post'>
Email: <input type='text' name='email' size='30' maxlength='55' value='$user[email]'><br>
Forum Title: <input type='text' name=title' size='30' maxlength='55' value='$user[title]'><br>
Location: <input type='text' name='location' size='30' maxlength='40' value='$user[location]'><br>
Age: <input type='text' name='age' size='3' maxlength='3' value='$user[age]'><br>
Sex: <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>
Signature: <textarea name='sig'>$user[sig]</textarea> <br>
<input type='submit' value='Update'>
</form>";
}
}else{
echo "You are not logged in.";
}
echo "<center>";
?>

So can someone help meh pls?

Also, when i read a PM, it logs meh out and my users, its the same for editing, replying and make a thread in the forum.
Posted on Wednesday 26th March 2008 at 01:09 PM
Dalez
templates/default/images/noavatar.png's Avatar
Junior Member
Why does no one reply? I really need help!
Posted on Wednesday 26th March 2008 at 06:31 PM
ShadowMage
templates/default/images/noavatar.png's Avatar
Senior Member
replace:
Code

$update = mysql_query("UPDATE `members` SET `email` = '$email', `title` = '$title', `sex` = '$sex', `age` = '$age', `location` = '$location', 'sig' = '$sig' WHERE `username` = '$logged[username]'");


with
Code

$update = mysql_query("UPDATE `members` SET `email` = '$email', `title` = '$title', `sex` = '$sex', `age` = '$age', `location` = '$location', 'sig' = '$sig' WHERE `username` = '$logged[username]'") or die(mysql_error());


then post if errors come up x]
Posted on Wednesday 26th March 2008 at 06:33 PM
Dalez
templates/default/images/noavatar.png's Avatar
Junior Member
I've sorted that out :P

But now i have another problem, inventory doesn't work.
Posted on Friday 4th April 2008 at 11:05 PM
UrbanTwitch
templates/default/images/noavatar.png's Avatar
Senior Member
Inventory? Care to explain more?