PHP User System - Adding New F

Posted on Monday 7th April 2008 at 11:32 PM
UrbanTwitch
UrbanTwitch's Avatar
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. <?php session_start(); //allows session ?>
  2. <html><?php echo "<title>Editing profile for $user[username] | sodaDome.com</title>"; ?>
  3. <head>
  4. <link rel="stylesheet" href="https://sodadome.com/images/CoolWater.css" type="text/css" />
  5. </head>
  6. <body>
  7. <?php
  8. include "config.php";
  9. echo "<center>";
  10. //checks see if there logged in
  11. if($logged[id])
  12. {
  13. if(isset($_GET['update'])){
  14. //Email
  15. $email = addslashes(htmlspecialchars($_POST[email]));
  16. //Where you are
  17. $location = addslashes(htmlspecialchars($_POST[location]));
  18. //Your Age
  19. $age = (int)addslashes(htmlspecialchars($_POST[age]));
  20. //Gender
  21. $sex = addslashes(htmlspecialchars($_POST[sex]));
  22. //Sodaplay.com account
  23. $sodaname = addslashes(htmlspecialchars($_POST[sodaname]));
  24. //Avatar
  25. $avatar = addslashes(htmlspecialchars($_POST[avatar]));
  26. //MSN
  27. $msn = (int)addslashes(htmlspecialchars($_POST[msn]));
  28. //AIM
  29. $aim = (int)addslashes(htmlspecialchars($_POST[aim]));
  30. //WebPage
  31. $sitename = addslashes(htmlspecialchars($_POST[sitename]));
  32. //Site URL
  33. $siteurl = addslashes(htmlspecialchars($_POST[siteurl]));
  34. //Small Biography
  35. $smallbio = (int)addslashes(htmlspecialchars($_POST[smallbio]));
  36. //Personal Text
  37. $customeheader = (int)addslashes(htmlspecialchars($_POST[customeheader]));
  38. //Interests
  39. $interests = (int)addslashes(htmlspecialchars($_POST[interests]));
  40. //checks the sex if its ok
  41. if(($sex == "Male") || ($sex == "Female")){
  42. //updates there profile in the db
  43. $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]'");
  44. echo "Profile updated!";
  45. }
  46. //if the sex is invalid
  47. else{
  48. echo "Invalid sex input!";
  49. }
  50. }else{
  51. $getuser = mysql_query("SELECT * FROM `members` WHERE `username` = '$logged[username]'");
  52. $user = mysql_fetch_array($getuser);
  53. echo "<form name='form1' action='editprofile.php?update' method='post'>
  54. <fieldset style='width: 500'>
  55. <b>Avatar:</b> <input type='text' name='avatar' size='30' value='$user[avatar]'><br>
  56. <b>Email:</b> <input type='text' name='email' size='30' maxlength='55' value='$user[email]'><br>
  57. <b>Location:</b> <input type='text' name='location' size='30' maxlength='40' value='$user[location]'><br>
  58. <b>Age:</b> <input type='text' name='age' size='3' maxlength='3' value='$user[age]'><br>
  59. <b>Sex:</b> <select size='1' name='sex' value='$user[sex]'>
  60. <option value='Male' "; if($user[sex] == Male) {
  61. echo "selected"; }
  62. echo ">Male</option>
  63. <option value='Female' "; if($user[sex] == Female) {
  64. echo "selected"; }
  65. echo ">Female</option>
  66. </select><br>
  67. <B>Site Name:</b> <input type='text' name='siteurl' size='30' maxlength='55' value='$user[siteurl]'><br>
  68. <B>Site URL:</b> <input type='text' name='webpage' size='30' maxlength='55' value='$user[webpage]'><br>
  69. <b>sodaplay account:</b> https://sodaplay.com/creators/<input type=text name=sodaname size=20 maxlength=25 onkeydown=change_case(); onBlur=change_case(); value=$user[sodaname]><br><br>
  70. <input type='submit' value='Update'>
  71. </fieldset></form>";
  72. }
  73. }
  74. else
  75. {
  76. echo "You are not logged in.";
  77. }
  78. echo "<center>";
  79. ?>
  80. <script type="text/javascript">
  81. function change_case()
  82. {
  83. document.form1.sodaname.value=document.form1.sodaname.value.toLowerCase();
  84. }
  85. </script>
  86.  
  87. </body></html>


and here is members.php

PHP Code
  1. <?php session_start(); //allows session ?>
  2. <html><?php echo "<title>Member List | sodaDome.com</title>"; ?>
  3. <head>
  4. <link rel="stylesheet" href="https://sodadome.com/images/CoolWaterTable.css" type="text/css" />
  5. </head>
  6. <body>
  7. <?php
  8. include "config.php";
  9. echo "<center>";
  10. if(isset($_GET['user'])){ //if there trying to view a profile
  11. //gets the user name and makes it safe
  12. $username = addslashes($_GET[user]);
  13. //querys the db to find the username
  14. $getuser = mysql_query("SELECT * FROM `members` WHERE `username` = '$username'");
  15. //checks see if the username exists in the db
  16.  
  17. $usernum = mysql_num_rows($getuser);
  18. //if it don't exist
  19. if ($usernum == 0)
  20.  
  21. {
  22. //don't exist
  23.  
  24. echo ("User Not Found");
  25.  
  26. }
  27. //if it does exist then show there profile
  28. else
  29. {
  30. $user = mysql_fetch_array($getuser);
  31. echo "<fieldset style='width: 500'>
  32. <b>$user[username]'s Profile | sodaDome.com</b><br><br>
  33. <img src=$user[avatar] width=150px height=150px border=0><br><br>
  34. Last Seen: $user[last_seen]<br>
  35. <a href='friendrequest.php?user=$user[username]'>Add as Friend</a><br>
  36.  
  37. Email: $user[email]<br>
  38. Member No.: $user[id]<br>
  39. Website: <a href=$user[siteurl] target=_blank>$user[sitename]</a><br>
  40. Location: $user[location]<br>
  41. Sex: $user[sex]<br>
  42. Age: $user[age]<br>
  43. sodaplay account: <a href=https://sodaplay.com/creators/$user[sodaname] target=_blank>$user[sodaname]</a>
  44. </fieldset>";
  45.  
  46. }
  47. }
  48. else
  49. {
  50. //gets all the members from the database
  51. $getusers = mysql_query("SELECT * FROM `members` ORDER BY `id` ASC") or die(mysql_error());
  52. //loops there name out
  53. while ($user = mysql_fetch_array($getusers))
  54. {
  55. echo "<a href='members.php?user=$user[username]'>$user[username]</a><br>";
  56. }
  57. }
  58. echo "<center>";
  59. ?>
  60.  
  61. </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 'https://img91.imageshack.us/img91/5952/noavvysi4.png';? Right? I don't know.
Posted on Monday 9th June 2008 at 03:28 AM
Adam981
Adam981's Avatar
https://rmb-scripting.com/tutorials.php?tutorial&tid=111
Login or register to respond to this forum topic.