Anxious Posted April 11, 2009 Share Posted April 11, 2009 Hello, first of all, this is a big issue, I only have two errors that I cannot fix. I'm wondering if anyone can assist me all the way through until this is spot on. (It's nearly done) I started designing userprofiles yesterday, I was doing it non stop for about 10 hours. I eventually got to a point where I can test. So I did, I have an edit the user profile page, which works. However, the forum is set up like "Profile header, Location, School/Job, Marial Status, Likes, Dislikes, Music" The values, (I i only filled in the first 4 parts to test) come up, Profile header goes under slogan which is right, Location goes under location which is correct (Theres two locations, a default one, and a profile one, so that people who don't want to display the location have a choice using the 'profilelocation' the default location don't display on the profile), yet School/Job, and Martial status, ends up on the last 2 collumns of the database, which is dislikes and music. So the values are being entered in wrong and I've checked everything I can't fix it. Second problem, on the userprofile, It don't display the details. Where it says 'Name' or 'Date of Birth' etc, just comes up empty. ( I haven't added in likes dislikes and music yet on this part, because it'd be pointless if it don't work) Wondering if anyone can assist me through this, I will post codes once I know someone will help. Thanks. Link to comment https://forums.phpfreaks.com/topic/153600-user-profile-with-errors/ Share on other sites More sharing options...
Yesideez Posted April 11, 2009 Share Posted April 11, 2009 Your first problem will be tricky to diagnose without seeing code, same goes for second problem but make sure your query to extract the data from the table(s) is actually working. You can test this by ECHOing the query to the browser and pasting it into phpMyAdmin. If there are errors it'll give a better explanation as to why it doesn't work. Link to comment https://forums.phpfreaks.com/topic/153600-user-profile-with-errors/#findComment-807139 Share on other sites More sharing options...
Anxious Posted April 11, 2009 Author Share Posted April 11, 2009 Thank you for your response, these are the codes that will be needed to correct the problems. Database.php <?php function addNewUser($username, $password, $email, $day, $month, $year, $location, $gender){ $time = date("F j, Y, g:i"); $dob = $_POST['day'] . "/" . $_POST['month'] . "/" . $_POST['year']; /* If admin sign up, give admin user level */ if(strcasecmp($username, ADMIN_NAME) == 0){ $ulevel = ADMIN_LEVEL; }else{ $ulevel = USER_LEVEL; } $q = "INSERT INTO ".TBL_USERS." VALUES ('$username', '$password', '$ulevel', '$email', '$time', '$location', '$dob', '$gender', '0', '$slogan', '$profilelocation', '$schooljob', '$status', '$likes', '$dislikes', '$music')"; return mysql_query($q, $this->connection); } /** * updateUserField - Updates a field, specified by the field * parameter, in the user's row of the database. */ function updateUserField($username, $field, $value){ $q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'"; return mysql_query($q, $this->connection); } /* Get user info */ function getUserInfo($username){ $q = "SELECT * FROM ".TBL_USERS." WHERE username = '$username'"; $result = mysql_query($q, $this->connection); /* Error occurred, return given name by default */ if(!$result || (mysql_numrows($result) < 1)){ return NULL; } /* Return result array */ $dbarray = mysql_fetch_array($result); return $dbarray; } ?> Session.php <?php function editAccount($subslogan, $subprofilelocation, $schooljob, $status, $sublikes, $subdislikes, $submusic){ global $database, $form; //The database and form object /* Change Slogan */ if($subslogan){ $database->updateUserField($this->username,"slogan",$subslogan); } if($subprofilelocation){ $database->updateUserField($this->username,"profilelocation",$subprofilelocation); } if($subschooljob){ $database->updateUserField($this->username,"schooljob",$subschooljob); } if($substatus){ $database->updateUserField($this->username,"status",$substatus); } /* Change Likes */ if($sublikes){ $database->updateUserField($this->username,"likes",$sublikes); } /* Change Dislikes */ if($subdislikes){ $database->updateUserField($this->username,"dislikes",$subdislikes); } /* Change Music */ if($submusic){ $database->updateUserField($this->username,"music",$submusic); } /* Success! */ return true; } ?> Process.php <?php function procEditAccount(){ global $session, $form; /* Account edit attempt */ $retval = $session->editAccount($_POST['slogan'], $_POST['profilelocation'], $_POST['schooljob'], $_POST['status'], $_POST['likes'], $_POST['dislikes'], $_POST['music']); /* Account edit successful */ if($retval){ $_SESSION['useredit'] = true; header("Location: ".$session->referrer); } /* Error found with form */ else{ $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); header("Location: ".$session->referrer); } ?> (Note: userInfo is the profile info, and editAccount is the profile edit) Profile.php <?php $req_user_info = $database->getUserInfo($req_user); $req_user_info['slogan'] ?> Theres that kind above, or theres <?php $req_user_info = $database->getUserInfo($req_user); $session->user_info['slogan'] ?> Either one of the above don't work. (There to get the values, there are other fields, but if I can get one to work, I'm sure the others I could get to work) You won't need profile-edit.php, being as the form layout is, Profile Header(slogan); Location(profilelocation); School/Job(schooljob); Martial Status(status); Likes(likes); Dislikes(dislikes); Music(music); It saves the values, just in the wrong section of the database, the database itself, is set up in the same format, but with the 'addNewUser' values, which are in Database.php which come before the profile values. Is this what you'd need. Thanks. Link to comment https://forums.phpfreaks.com/topic/153600-user-profile-with-errors/#findComment-807149 Share on other sites More sharing options...
Anxious Posted April 11, 2009 Author Share Posted April 11, 2009 Can anyone help, thanks. Link to comment https://forums.phpfreaks.com/topic/153600-user-profile-with-errors/#findComment-807166 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.