View Single Post
  #1  
Old 05-14-2009, 09:28 PM
Bloodrun's Avatar
Bloodrun Bloodrun is offline
I am, who I am.
 
Join Date: Apr 2009
Posts: 532
Gender: Male
Credits: 28,655
Bloodrun
Send a message via Yahoo to Bloodrun
Default A quick Profile Add-on Modification

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:

Code:
  `aboutme` varchar(5000) NOT NULL,
Next, go to your account.php file, and find where it says:

PHP Code:

// 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:

PHP Code:
$aboutme=@mysql_result($result,$i,"ame"); 
PHP Code:
$ame stripslashes($ame); 
Then scroll down, to where it says:

PHP Code:
// 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:

PHP Code:
  <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:

PHP Code:
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:

PHP Code:
$aboutme $_POST["aboutme"];
$aboutme secure($aboutme); 
Then scroll down to where it says:

PHP Code:
// Run update queries...

$query "UPDATE ".$prefix."users SET newmessagenotify='".$newmsgnotify."' WHERE username='".$loggedinname."'";
mysql_query($query); 
And place the following in that group:

PHP Code:
$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:

PHP Code:

        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 '
PHP Code:
'' 
So it looks like this:

PHP Code:

        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:

PHP Code:
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:

PHP Code:
    $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:

PHP Code:
    // Show the user's profile page... 
And place the following within the '$article_content':

PHP Code:
<b>About Me:</b><br".$aboutme."<br
And your down. Don't be afraid to ask questions. I won't bite. =D
Reply With Quote