Signature Addon to forum


First add this in PHPmyAdmin

SQL:
PHP Code
  1. ALTER TABLE `members` ADD `sig` BLOB(100000000) NOT NULL


Now open forum.php and find

PHP Code
  1. case 'forumdisplay':


We will be working in this section first off

Now find in forumdisplay

PHP Code
  1. if($thread[sticky] == Yes)
  2. {
  3. echo ("<td id='mains'><b>Sticky:</b> $bbctt2</td></tr>");
  4. }
  5. else
  6. {
  7. echo ("<td id='mains'><b>$bbctt2</b></td></tr>");
  8. }
  9. echo ("<tr>
  10. <td id='mains' align='center' width='120'><a href=javascript:void(window.open('members.php?user=$thread[poster]','client','status=1,width=400,height=250,top=60,left=60'))>$thread[poster]</a><br>
  11. <img src='$threadavatar[avatar]'>
  12. ");
  13. if ($logged[userlevel] == '4' || $logged[userlevel] == '6')
  14. {
  15. echo ("<br><a href='forum_mod.php?page=lock&id=$thread[id]'>Lock</a> - <a href='?page=editthread&id=$thread[id]'>Edit</a> - <a href='forum_mod.php?page=sticky&id=$thread[id]'>Sticky</a>");
  16. }
  17. if ($thread[poster] == $logged[username])
  18. {
  19. echo ("<br><a href='?page=editthread&id=$thread[id]'>Edit Post</a>");
  20. }
  21. echo ("
  22. </td><td id='mains' align='left' valign='top'>$bbctm</td></tr>");
  23. $fetch2 = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '$_GET[id]'");
  24. while ($posts = mysql_fetch_array($fetch2))
  25. {
  26. $postsmessage = "$posts[message]";
  27. $bbcpm = BBCODE($postsmessage);
  28.  
  29. $fetch4 = mysql_query("SELECT * FROM `members` WHERE `username` = '$posts[poster]'");
  30. $postsavatar = mysql_fetch_array($fetch4);
  31.  
  32. echo ("<tr>
  33. <td id='fields' align='center'>$posts[poster]
  34. <br>
  35. <img src='$postsavatar[avatar]'>
  36. ");
  37. if ($logged[userlevel] == '4' || $logged[userlevel] == '6')
  38. {
  39. echo ("<br><a href='forum_mod.php?page=delete&id=$posts[id]'>Delete</a> - <a href='?page=editpost&id=$posts[id]'>Edit</a>");
  40. }
  41. if ($logged[username] == $posts[poster])
  42. {
  43. echo ("<br><a href='?page=editpost&id=$posts[id]'>Edit Post</a>");
  44. }
  45. echo ("
  46. </td>
  47. <td id='fields' align='left' valign='top'>$bbcpm</td>
  48. </tr>");


And replace with:

PHP Code
  1. if($thread[sticky] == Yes)
  2. {
  3. echo ("<td id='mains'><b>Sticky:</b> $bbctt2</td></tr>");
  4. }
  5. else
  6. {
  7. echo ("<td id='mains'><b>$bbctt2</b></td></tr>");
  8. }
  9. echo ("<tr>
  10. <td id='mains' align='center' width='120' rowspan='2'><a href=javascript:void(window.open('members.php?user=$thread[poster]','client','status=1,width=400,height=250,top=60,left=60'))>$thread[poster]</a><br>
  11. <img src='$threadavatar[avatar]'>
  12. ");
  13. if ($logged[userlevel] == '4' || $logged[userlevel] == '6')
  14. {
  15. echo ("<br><a href='forum_mod.php?page=lock&id=$thread[id]'>Lock</a> - <a href='?page=editthread&id=$thread[id]'>Edit</a> - <a href='forum_mod.php?page=sticky&id=$thread[id]'>Sticky</a>");
  16. }
  17. if ($thread[poster] == $logged[username])
  18. {
  19. echo ("<br><a href='?page=editthread&id=$thread[id]'>Edit Post</a>");
  20. }
  21. echo ("
  22. </td><td id='mains' align='left' valign='top'>$bbctm</td></tr>
  23. <tr>
  24. <td id='mains'>$threadavatar[sig]</td></tr>");
  25. $fetch2 = mysql_query("SELECT * FROM `forum_posts` WHERE `thr_id` = '$_GET[id]'");
  26. while ($posts = mysql_fetch_array($fetch2))
  27. {
  28. $postsmessage = "$posts[message]";
  29. $bbcpm = BBCODE($postsmessage);
  30.  
  31. $fetch4 = mysql_query("SELECT * FROM `members` WHERE `username` = '$posts[poster]'");
  32. $postsavatar = mysql_fetch_array($fetch4);
  33.  
  34. echo ("<tr>
  35. <td id='fields' align='center' rowspan='2'>$posts[poster]
  36. <br>
  37. <img src='$postsavatar[avatar]'>
  38. ");
  39. if ($logged[userlevel] == '4' || $logged[userlevel] == '6')
  40. {
  41. echo ("<br><a href='forum_mod.php?page=delete&id=$posts[id]'>Delete</a> - <a href='?page=editpost&id=$posts[id]'>Edit</a>");
  42. }
  43. if ($logged[username] == $posts[poster])
  44. {
  45. echo ("<br><a href='?page=editpost&id=$posts[id]'>Edit Post</a>");
  46. }
  47. echo ("
  48. </td>
  49. <td id='fields' align='left' valign='top'>$bbcpm</td>
  50. </tr>
  51. <tr><td id='fields'>$postsavatar[sig]</td></tr>");


Save and Close, all i did here was displayed the sig on the forum posts.

Now, open editprofile.php

find:
PHP Code
  1. if($logged[id]) {
  2. if(isset($_GET['update'])) {
  3. $email = addslashes(htmlspecialchars($_POST[email]));
  4. $location = addslashes(htmlspecialchars($_POST[location]));
  5. $age = (int)addslashes(htmlspecialchars($_POST[age]));
  6. $sex = addslashes(htmlspecialchars($_POST[sex]));
  7. //checks the sex if its ok
  8. if(($sex == "Male") || ($sex == "Female")) {
  9. //updates there profile in the db
  10. $update = mysql_query("UPDATE `members` SET `email` = '$email', `sex` = '$sex', `age` = '$age', `location` = '$location' WHERE `username` = '$logged[username]'");
  11. echo "Profile updated!";


And change it to:
PHP Code
  1. if($logged[id]) {
  2. if(isset($_GET['update'])) {
  3. $email = addslashes(htmlspecialchars($_POST[email]));
  4. $sig = addslahes(htmlspecialchars($_POST[sig]));
  5. $location = addslashes(htmlspecialchars($_POST[location]));
  6. $age = (int)addslashes(htmlspecialchars($_POST[age]));
  7. $sex = addslashes(htmlspecialchars($_POST[sex]));
  8. //checks the sex if its ok
  9. if(($sex == "Male") || ($sex == "Female")) {
  10. //updates there profile in the db
  11. $update = mysql_query("UPDATE `members` SET `email` = '$email', `sig` = '$sex', `sex` = '$sex', `age` = '$age', `location` = '$location' WHERE `username` = '$logged[username]'");
  12. echo "Profile updated!";


Then find:
PHP Code
  1. echo "<form action='editprofile.php?update' method='post'>
  2. Email: <input type='text' name='email' size='30' maxlength='55' value='$user[email]'><br>
  3. Location: <input type='text' name='location' size='30' maxlength='40' value='$user[location]'><br>
  4. Age: <input type='text' name='age' size='3' maxlength='3' value='$user[age]'><br>
  5. Sex: <select size='1' name='sex' value='$user[sex]'>
  6. <option value='Male' "; if($user[sex] == Male) {
  7. echo "selected"; }
  8. echo ">Male</option>
  9. <option value='Female' "; if($user[sex] == Female) {
  10. echo "selected"; }
  11. echo ">Female</option>
  12. </select><br>
  13. <input type='submit' value='Update'>
  14. </form>";


And change it to:

PHP Code
  1. echo "<form action='editprofile.php?update' method='post'>
  2. Email: <input type='text' name='email' size='30' maxlength='55' value='$user[email]'><br>
  3. Location: <input type='text' name='location' size='30' maxlength='40' value='$user[location]'><br>
  4. Age: <input type='text' name='age' size='3' maxlength='3' value='$user[age]'><br>
  5. Signature: <textarea name='sig'>$user[sig]</textarea>
  6. Sex: <select size='1' name='sex' value='$user[sex]'>
  7. <option value='Male' "; if($user[sex] == Male) {
  8. echo "selected"; }
  9. echo ">Male</option>
  10. <option value='Female' "; if($user[sex] == Female) {
  11. echo "selected"; }
  12. echo ">Female</option>
  13. </select><br>
  14. <input type='submit' value='Update'>
  15. </form>";


All i did here was add a field for you to edit the sig, and it to be submitted to the database..

Should work, un tested as the version i wrote for my forum was made with diffrent variables but any problems please post i'll be happy to help.
new2old's Avatar
Author:
Views:
3,468
Rating:
Posted on Sunday 20th April 2008 at 12:45 AM
cyruswu
cyruswu's Avatar
Darklight for some reason the exact same description is in my php and mysql book.
Posted on Sunday 20th April 2008 at 12:41 AM
cyruswu
cyruswu's Avatar
Darklight for some reason the exact same description is in my php and mysql book.
Posted on Sunday 24th February 2008 at 10:11 PM
darklight19
darklight19's Avatar
I copied it from the mySQL site lol
Posted on Sunday 24th February 2008 at 10:04 PM
Zegzeima
Zegzeima's Avatar
Ah ok thanks :)
Posted on Sunday 24th February 2008 at 10:00 PM
darklight19
darklight19's Avatar
A BLOB is a binary large object that can hold a variable amount of data. The four BLOB types are TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB. These differ only in the maximum length of the values they can hold. The four TEXT types are TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT. These correspond to the four BLOB types and have the same maximum lengths and storage requirements.
Posted on Sunday 24th February 2008 at 09:55 PM
Zegzeima
Zegzeima's Avatar
Whats different between TEXT and BLOB?
Posted on Saturday 16th February 2008 at 11:31 AM
new2old
new2old's Avatar
No problem ;)
Posted on Friday 15th February 2008 at 11:55 PM
zackcez
zackcez's Avatar
thank you very much :)
Posted on Friday 15th February 2008 at 10:35 PM
ShadowMage
ShadowMage's Avatar
thanks :P This helps me out cause i've got a big list of things to do :x