PDA

View Full Version : A quick Profile Add-on Modification


Bloodrun
05-14-2009, 09:28 PM
Like the title says, a quick Profile Add-on Modification.
What does that mean?
I will show you how to make a new profile add-on, and make it work ;)

Profile Add-on Includes:

How to add a new option in your account.php file
How to make it so it shows up in your profile.php


Will Include:

A more advanced looking account.php
A friends option
A 'customize' your own profile option.


Preview:]
(Image is too large for page.)
http://i43.tinypic.com/2s6sm5e.jpg

First things first, whatever you want to add to your profile/account file, you MUST add to your database, and to do that, all you need to do, is come up with a name, and place into your 'adopts_user' table.
For the sake of this tutorial, I will be showing you how to add a very simple 'about me' section to your profile.

So go ahead and add this to your 'adopts_user' table:


`aboutme` varchar(5000) NOT NULL,


Next, go to your account.php file, and find where it says:



// Get the user's account details from the database...

$query = "SELECT * FROM ".$prefix."users WHERE username='$loggedinname'";
$result = mysql_query($query);
$num = mysql_numrows($result);

//Loop out code
$i=0;
while ($i < 1) {


And place the following two things, in the appropriate groups:


$aboutme=@mysql_result($result,$i,"ame");



$ame = stripslashes($ame);


Then scroll down, to where it says:


// Show the form...

if($newmessagenotify == 1){
$box = "<input name='newmsgnotify' type='checkbox' id='newmsgnotify' value='1' checked>";
}
else{
$box = "<input name='newmsgnotify' type='checkbox' id='newmsgnotify' value='1'>";
}

$article_content = $article_content."<br><br><br><br><br>

<form name='form1' method='post' action='accountpost.php'>


And insert the following any where in that form:


<p>About Me: <br>
<textarea name='aboutme' type='text' id='aboutme' cols='40' rows='3'>".$ame."</textarea>
</p>


Now that's it for the account.php file.

Now go to your accountpost.php file, and find where it says:


else if($act == "changesettings"){

// We are changing the settings

$newmsgnotify = $_POST["newmsgnotify"];
$newmsgnotify = preg_replace("/[^a-zA-Z0-9@._-]/", "", $newmsgnotify);
$newmsgnotify = secure($newmsgnotify);


And place the following in that group:


$aboutme = $_POST["aboutme"];
$aboutme = secure($aboutme);


Then scroll down to where it says:


// Run update queries...

$query = "UPDATE ".$prefix."users SET newmessagenotify='".$newmsgnotify."' WHERE username='".$loggedinname."'";
mysql_query($query);


And place the following in that group:


$query = "UPDATE ".$prefix."users SET aboutme='".$aboutme."' WHERE username='".$loggedinname."'";
mysql_query($query);


Now before we do ANYTHING else, go to your register.php file, and find where it says:



mysql_query("INSERT INTO ".$prefix."users VALUES ('', '$username', '$pass1', '$email', '3', '1', '$date', '0')");


And add this to the end:

Note: it is not a quotation mark, it is a double tick ' and '

, ''


So it looks like this:



mysql_query("INSERT INTO ".$prefix."users VALUES ('', '$username', '$pass1', '$email', '3', '1', '$date', '0', '')");


Now, to make this all show up on your profile page ;D

Go to your profile.php and find where it says:


if($user != ""){

// We have specified a specific user who we are showing a profile for...
// See if the user exists...

$query = "SELECT * FROM ".$prefix."users WHERE username = '".$user."'";
$result = mysql_query($query);
$num = mysql_numrows($result);

if($num > 0){

$i=0;
while ($i < 1) {


And place the following in a that group:


$aboutme=@mysql_result($result,$i,"aboutme");


Now you can add the part where if a user hasn't entered anything in for the category, it will say something like "No information given" but, I'm going to show it.

Next scroll down to where it says:


// Show the user's profile page...


And place the following within the '$article_content':


<b>About Me:</b><br> ".$aboutme."<br>


And your down. Don't be afraid to ask questions. I won't bite. =D

rainbelly
05-15-2009, 07:20 AM
Cool!

However, I am getting an error on the MySQL:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`aboutme` VARCHAR(5000) NOT NULL,' at line 2

SJC
05-15-2009, 02:21 PM
Quick question. Do you have to add another ,'' at the end of :
mysql_query("INSERT INTO ".$prefix."users VALUES ('', '$username', '$pass1', '$email', '3', '1', '$date', '0', '')");
if you wanted to insert another profile field?

Bloodrun
05-15-2009, 03:01 PM
Cool!

However, I am getting an error on the MySQL:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`aboutme` VARCHAR(5000) NOT NULL,' at line 2


That has to do with how you put it in your database. Each new line has to end with a comma.


Quick question. Do you have to add another ,'' at the end of :
mysql_query("INSERT INTO ".$prefix."users VALUES ('', '$username', '$pass1', '$email', '3', '1', '$date', '0', '')");
if you wanted to insert another profile field?


Yes you do, lol don't forget that. It will frustrate you beyond belief. ;)

SJC
05-15-2009, 03:07 PM
Okay, just wanted to make sure :).

Bloodrun
05-15-2009, 03:08 PM
Okay, just wanted to make sure :).


Lol okie dokie.
Oh, if you have any suggestions for new modifications, or want something made for your site. Just drop me a PM =D

mapleblade
05-16-2009, 07:05 AM
it works fine, but if i add something it only sais on profile "about me:"
after that nothing.

Bloodrun
05-16-2009, 02:28 PM
it works fine, but if i add something it only sais on profile "about me:"
after that nothing.


Then it has to do with how your calling it on your profile page.
First check to make sure its even going into the database.

12345
05-22-2009, 07:55 AM
I have do everything in instructions but profile is not looking like this
http://i43.tinypic.com/2s6sm5e.jpg
And I already have this:
`aboutme` varchar(5000) NOT NULL,
from your other mod

Bloodrun
05-22-2009, 08:16 AM
I have do everything in instructions but profile is not looking like this
http://i43.tinypic.com/2s6sm5e.jpg
And I already have this:
`aboutme` varchar(5000) NOT NULL,
from your other mod


Are you sure you added the .html file for the users profile?
Because without that, the profile will not look like its suppose to.

rosepose
05-26-2009, 11:35 AM
Uh oh.... Well, I got up to the bit where you edit the register.php file, and so to be safe I thought I'd try creating another account, right? It told be something was very, very wrong, and I suspect it's the code I put in to register.php. Help?

Bloodrun
05-26-2009, 11:47 AM
Uh oh.... Well, I got up to the bit where you edit the register.php file, and so to be safe I thought I'd try creating another account, right? It told be something was very, very wrong, and I suspect it's the code I put in to register.php. Help?


Okay I need two things from you.

I need you to copy and paste your current register file here, and I need to how many sets are in your 'adopts_users' table.

rosepose
05-26-2009, 03:44 PM
Oh.... I'm sorry, I undid everything. I'll do it up again on a backup script, hang on....

shiningheart
06-07-2009, 06:35 PM
This code rocks, but I have a problem. Is there a way that when the person views the other person's profile, it can also the list their pets? Because if some people don't have anywhere to post their pets, how are they going to advertise them and get more clicks? So I was wondering if you could give me the code so I can add the pets to it.

Bloodrun
06-07-2009, 06:58 PM
This code rocks, but I have a problem. Is there a way that when the person views the other person's profile, it can also the list their pets? Because if some people don't have anywhere to post their pets, how are they going to advertise them and get more clicks? So I was wondering if you could give me the code so I can add the pets to it.


Yes, actually, lol I forgot that I removed that part out, what you need to do is, go to your profile2.php and,

place this:


$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE owner = '".$user."'";
$result = mysql_query($query);
$numpets = mysql_numrows($result);


Right after this:


if($yahoo == ""){
$yahoo = "No YIM Information Given";
}


$i++;
}


Then where ever you want the pets to show up, place this into that section (note, the section will look something like $article_content, $about_me, etc.. etc):


<b>Number Of Pets Owned:</b> ".$numpets."<br><br>
<b><u>".$usersname."'s Pets:</u></b><br><br>


Then, go to the end of the section you placed that bit of code in, (the end of the section will be marked with ";) and immediately after that, place this:


if($numpets > 0){

$i=0;
while ($i < $numpets) {

$aid=@mysql_result($result,$i,"aid");
$image = getcurrentimage($aid);

$article_content = $article_content."<a href='levelup.php?id=".$aid."'><img src='".$image."' border='0'></a>";


$i++;
}
}
else{
$article_content = $article_content."This user currently does not have any pets.";
}


You have to make sure you do not place that bit of quote in a section, or else you will get an error.

shiningheart
06-07-2009, 07:21 PM
I did exactly what you said but it didnt show up.

http://flaredrhapsody.co.cc/profile2.php?user=shiningheart

It is supposed to show up under Member's Stats, but its not... xDD

Bloodrun
06-07-2009, 07:33 PM
I did exactly what you said but it didnt show up.

http://flaredrhapsody.co.cc/profile2.php?user=shiningheart

It is supposed to show up under Member's Stats, but its not... xDD


Please copy and paste your profile2.php file here, and ill fix the problem for you.

BTW you turned private messaging off, so I can't reply to your PM's.

shiningheart
06-07-2009, 07:33 PM
Oh okay, Oops! And one minute....[hr]
<?php

// ************************************************** ********************
// Rusnak PHP Adoptables Script
// Copyright 2009 Brandon Rusnak
// For help and support: http://www.rusnakweb.com/forum/
//
// Redistribution prohibited without written permission
// File ID: profile2.php
// Shows a user profile, or a member list.
// ************************************************** ********************

// Wake the sleeping giant

// ************************************************** ********************
// Basic Configuration Info
// ************************************************** ********************

include("inc/functions.php");
include("inc/config.php");
include("lang/lang.php");

$themeurl = "templates/default/usertemp.html";

$template = replace(':DISPLAYPIC:',$displaypic,$template);
$template = replace(':DISPLAYQUOTE:',$display_quote,$template) ;
$template = replace(':ARTICLESTATS:',$article_stats,$template) ;
$template = replace(':ARTICLEABOUT:',$article_about,$template) ;
$template = replace(':ARTICLEABOUTME:',$aboutme,$template);
$template = replace(':USERCSS:',$usercss,$template);

// ************************************************** ********************
// Define our top links by calling getlinks()
// ************************************************** ********************

$links = getlinks();

// ************************************************** ********************
// Define our ads by calling getads()
// ************************************************** ********************

$ads = getads("any");

// ************************************************** ********************
// Grab any dynamic article content from the content table
// ************************************************** ********************

$pagecontent = getsitecontent("index");
$article_title = $pagecontent[title];
$article_content = $pagecontent[content];
$article_content = nl2br($article_content);

// ************************************************** ********************
// Grab any settings that we will need for the current page from the DB
// ************************************************** ********************

$browsertitle = grabanysetting("browsertitle");
$sitename = grabanysetting("sitename");
$slogan = grabanysetting("slogan");


// ************************************************** ********************
// Check and see if the user is logged in to the site
// ************************************************** ********************

$loginstatus = logincheck();
$isloggedin = $loginstatus[loginstatus];
$loggedinname = $loginstatus[username];

// ************************************************** ********************
// End Prepwork - Output the page to the user
// ************************************************** ********************

// This page handles user profiles and shows the site members...



$user = $_GET["user"];

$user = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $user);

$user = secure($user);



$page = $_GET["page"];

$page = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $page);

$page = secure($page);



if($user != ""){



// We have specified a specific user who we are showing a profile for...

// See if the user exists...



$query = "SELECT * FROM ".$prefix."users WHERE username = '".$user."'";

$result = mysql_query($query);

$num = mysql_numrows($result);



if($num > 0){



$i=0;

while ($i < 1) {



$usersname=@mysql_result($result,$i,"username");

$usersgroup=@mysql_result($result,$i,"usergroup");


$status=@mysql_result($result,$i,"status");




$website=@mysql_result($result,$i,"website");

$aim=@mysql_result($result,$i,"aim");

$yahoo=@mysql_result($result,$i,"yahoo");

$msn=@mysql_result($result,$i,"msn");

$membersince=@mysql_result($result,$i,"membersince");

$ame=@mysql_result($result,$i,"ame");

$location=@mysql_result($result,$i,"location");

$age=@mysql_result($result,$i,"age");

$occupation=@mysql_result($result,$i,"occupation");

$interests=@mysql_result($result,$i,"interests");

$profilepic=@mysql_result($result,$i,"profilepic");

$displayquote=@mysql_result($result,$i,"displayquote");

$usercss=@mysql_result($result,$i,"usercss");



if($website == ""){

$website = "No Website Information Given";

}

else{

$website = "<a href='".$website."' target='_blank'>".$website."</a>";

}



if($msn == ""){

$msn = "No MSN Information Given";

}



if($aim == ""){

$aim = "No AIM Information Given";

}



if($yahoo == ""){

$yahoo = "No YIM Information Given";

}





$i++;

}




$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE owner = '".$user."'";
$result = mysql_query($query);
$numpets = mysql_numrows($result);












$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE owner = '".$user."'";

$result = mysql_query($query);

$numpets = mysql_numrows($result);



// Show the user's profile page...



if($status == "yes") {
$userdisp = "".$usersname."'s Profile<p>
Status: <b>Online!</b>";
}
elseif($status == "") {
$userdisp = "".$usersname."'s Profile <p> Status: <b>Offline!</b>";
}



$article_title = "$userdisp";




$displaypic = "<img src='".$profilepic."'>";
$display_quote = "".$displayquote."<br>".$userdisp."<br>";
$aboutme = " <b>About Me:</b><br> ".$ame."<br> <b>Interests:</b><br> ".$interests."<br>";
$article_content = "
<b><u>".$lang_basic_info."".$usersname.":</u></b></a><br><br>
<img src='templates/icons/web.gif'> ".$website."<br>
<img src='templates/icons/aim.gif'> ".$aim."<br>
<img src='templates/icons/msn.gif'> ".$msn."<br>
<img src='templates/icons/yahoo.gif'> ".$yahoo."<br>
<img src='templates/icons/title.gif'> <a href='messages.php?act=newpm&user=".$usersname."'>Send ".$usersname." a Private Message</a><br><br>";
$article_stats = "
<b><u>".$usersname."'s Stats:</b></u></a><br><br>
<b>Member Since:</b> ".$membersince."<br><br>
<b>Number Of Pets Owned:</b> ".$numpets."<br><br>
<b><u>".$usersname."s Pets:</u></b><br><br>";

if($numpets > 0){

$i=0;
while ($i < $numpets) {

$aid=@mysql_result($result,$i,"aid");
$image = getcurrentimage($aid);

$article_content = $article_content."<a href='levelup.php?id=".$aid."'><img src='".$image."' border='0'></a>";


$i++;
}
}
else{
$article_content = $article_content."This user currently does not have any pets.";
}










$article_about = "
<b><u>About ".$usersname.":</b></u></a><br><br>
<b>Location:</b> ".$location."<br>
<b>Age:</b> ".$age."<br>
<b>Occupation:</b> ".$occupation."<br> ";





}

}
// ************************************************** ********************
// Begin Template Definition
// ************************************************** ********************

//Define our current theme
$file = $themeurl;

// Do the template changes and echo the ready template
$template = file_get_contents($file);

$template = replace(':ARTICLETITLE:',$article_title,$template) ;
$template = replace(':ARTICLECONTENT:',$article_content,$templ ate);
$template = replace(':ARTICLEDATE:',$article_date,$template);

$template = replace(':BROWSERTITLE:',$browsertitle,$template);
$template = replace(':SITENAME:',$sitename,$template);

$template = replace(':DISPLAYPIC:',$displaypic,$template);
$template = replace(':DISPLAYQUOTE:',$display_quote,$template) ;
$template = replace(':ARTICLESTATS:',$article_stats,$template) ;
$template = replace(':ARTICLEABOUT:',$article_about,$template) ;
$template = replace(':ARTICLEABOUTME:',$aboutme,$template);
$template = replace(':USERCSS:',$usercss,$template);

//Define our links
$template = replace(':LINKSBAR:',$links,$template);

//Get the content for the side bar...

$sidebar = getsidebar();
$template = replace(':SIDEFEED:',$sidebar,$template);

//Get the ad content...
$template = replace(':ADS:',$ads,$template);

//Get the slogan info
$template = replace(':SLOGAN:',$slogan,$template);


echo $template;

// ************************************************** ********************
// End Template Definition
// ************************************************** ********************



?>

There is the profile2.php code.[hr]
Turned on my Private Messages ;) And thank you for all the help, BTW! :)[hr]
*swingslegswhilewaitingforaresponse* :)[hr]
Okay, I messed with it a bit, and finally, I got the pets to show! *cheers* But now the problem is, for some odd reason, the adoptables are under all the messaging information, instead of under where it says _____ Pets...

Bloodrun
06-07-2009, 10:15 PM
Then just move

<b>Number Of Pets Owned:</b> ".$numpets."<br><br>
<b><u>".$usersname."s Pets:</u></b><br><br>


Around, untill its where you want it.