View Single Post
  #1  
Old 01-17-2011, 07:35 PM
PTGigi's Avatar
PTGigi PTGigi is offline
Crazily Friendly~HoF
 
Join Date: Jul 2009
Location: Somewhere >.>
Posts: 370
Gender: Female
Credits: 26,315
PTGigi
Default Profile Add-Ons :3

Right! So I made a useful script! It's just a few minor profile add-ons Stuff like:
-Your Gender (dur)
-Your Nickname (helpful!)
-Your Favorite Color (RAINBOW *shot*)
-A bio! YAY!
-Your favorite adoptable!
-A small bio for your favorite adoptable!

So now to get this stuff installed we start by adding in the tables!

Go to the user table and add in these at the bottom:
profile varchar(500) utf8_general_ci Null
color varchar(20) utf8_general_ci Null
about varchar(200) utf8_general_ci Null
favpet int(11) Null
gender varchar(10) utf8_general_ci not null Unknown (<--that's the 'not null' part :3)
nickname varchar(40) utf8_general_ci Null

Now we go to opening up the 'register.php' (do that now *sits and waits* done? Okay!)

Now go down and find something like this:
PHP Code:
    else if($emailisvalid != "yes"){

    
//Email address is not valid or is a fake

    
$article_title "Email address is not valid";
    
$article_content $emailinvalid;

    }
    else{

    
//All checks are done, actually create the user's account on the database

    
$date date('Y-m-d');

    
mysql_query("INSERT INTO ".$prefix."users VALUES ('', '$username', '$pass1','$email', '500', '50', '100', '200', '100', '5', '3','1', '$date', '0','','','','','', '0', '', '', '', '', '', 'Unknown', '')");

    
//Now that we have created the user, let's log them in... 
Now see that whole mysql_query? DO NOT PASTE. That's mine, I have 6 cash types, you probably don't >.> You should add in:
Code:
, '', '', '', '', 'Unknown', ''
after your last entry but before the )");

All good? Okay! Now that just made it so people can register properly. We don't want that messed up D:

Now we should edit this information, why show it when we can't edit it? Now open up your Account.php

Go fine (yours will be different!):
PHP Code:
if($act == ""){

// No action specified

$article_title $loggedinname."'s Computer";
$article_content "BZZT...Welcome! <br>Checking name and password...checking...checking...<br>Name and password verfied. Welcome ".$loggedinname."<br>
Choose one of the options below to manage your account. You can change settings that involve your <a href='/myadopts.php'>Pokemon</a>, your <a href='profile.php?user="
.$loggedinname."'>Profile</a> page, and your account via this system.<br><br>
<b><u>Options:</u></b><br><br>
<a href='myadopts.php'>Manage your Pokemon</a><br>
<a href='profile.php?user="
.$loggedinname."'>View Profile</a><br>
<a href='account.php?act=changeemail'>Change Email Address</a><br>
<a href='account.php?act=changepass'>Change Password</a><br>
<a href='account.php?act=changesettings'>Change Settings and Profile Info</a><br>
<a href='account.php?act=moreprofile'>More Profile Settings</a>"
;


See the last one, "More Profile Settings"? You'll need that link in there, so add this after Change Settings:
Code:
<br>
<a href='account.php?act=moreprofile'>More Profile Settings</a>
MAKE SURE YOU BUT THIS BEFORE THE ";

Now scroll down and find this:
PHP Code:
else if($act == "changesettings"){

// We are changing the settings

$article_title $lang_changesettings_title;
$article_content $lang_changesettings."<br>";

// 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) {

$newmessagenotify=@mysql_result($result,$i,"newmessagenotify"); 
$website=@mysql_result($result,$i,"website");
$aim=@mysql_result($result,$i,"aim");
$yahoo=@mysql_result($result,$i,"yahoo");
$msn=@mysql_result($result,$i,"msn");

$website stripslashes($website);
$aim stripslashes($aim);
$yahoo stripslashes($yahoo);
$msn stripslashes($msn);


$i++;
}

// 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."<form name='form1' method='post' action='accountpost.php'>
  <p>"
.$box."
  Notify me via email when I receive a new message or reward code</p>
  <p><u>Publically Viewable Details: </u></p>
  <p>Website: 
    <input name='website' type='text' id='website' value='"
.$website."'>
</p>
  <p>AIM Username: 
    <input name='aim' type='text' id='aim' value='"
.$aim."'>
</p>
  <p>YIM Username: 
    <input name='yim' type='text' id='yim' value='"
.$yahoo."'>
</p>
  <p>MSN Username: 
    <input name='msn' type='text' id='msn' value='"
.$msn."'>
    <input name='act' type='hidden' id='act' value='changesettings'>
</p>
  <p>
    <input type='submit' name='Submit' value='Submit Details'>
  </p>
</form>"
;




Now directly after that paste this in:
PHP Code:
else if($act == "moreprofile"){
// We are changing the settings

$article_title "Editing Profile Setting";
$article_content "This page will allow you to change extra features of your profile page. These features are not mandatory but will add an extra dimension to your public profile page.<br>";

// 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) {

$profile=@mysql_result($result,$i,"profile"); //user bio
$color=@mysql_result($result,$i,"color");
$about=@mysql_result($result,$i,"about"); //about the fav pet
$favpet=@mysql_result($result,$i,"favpet");
$gender=@mysql_result($result,$i,"gender");
$nickname=@mysql_result($result,$i,"nickname");

$i++;
}

// Show the form...
if ($gender == "Male"){
$gen="<input type='radio' name='gender' value='Unknown'>Unknown/Hidden<br>
    <input type='radio' name='gender' value='Male' checked> Male<br>
<input type='radio' name='gender' value='Female'> Female"
;
}
else if (
$gender == "Female"){
$gen="<input type='radio' name='gender' value='Unknown'>Unknown/Hidden<br>
    <input type='radio' name='gender' value='Male'> Male<br>
<input type='radio' name='gender' value='Female' checked> Female"
;
}
else {
$gen="<input type='radio' name='gender' value='Unknown' checked>Unknown/Hidden<br>
    <input type='radio' name='gender' value='Male'> Male<br>
<input type='radio' name='gender' value='Female'> Female"
;
}


$article_content $article_content."<form name='form1' method='post' action='accountpost.php'>
  <p><u>Profile Details: </u></p>
<p>Nickname:     <input name='nickname' type='text' id='nickname' value='"
.$nickname."'></p>
    <p>Gender:<br>
"
.$gen."</p>
<p>Favorite Color:    <input name='color' type='text' id='color' value='"
.$color."'> (please, colors only)</p>
  <p>Your Bio: 
    <textarea name='profile' cols='45' rows='4' id='profile'>"
.$profile."</textarea>Here is a bio for yourself, the maximum number of characters you can use is 500. You can write whatever you want but abide by the </a href='tos.php'>ToS</a> and do NOT post content that involves an advertisement, vulgar language, or any other acts that could get your account banned. BBC is NOT useable for this. Feel free to tell the world whatever you want about yourself!</p>

  <p><u>Pet Spotlight Details: </u></p>
  <p>Favorite Pet ID: 

    <select name='favpet' id='favpet'>
      <option value='' selected>No Pokemon Selected</option>"
;
      
// We need to stop here and fetch our adoptables...

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

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

    
$aid=@mysql_result($result,$i,"aid");
    
$name=@mysql_result($result,$i,"name");
    
    
$article_content $article_content."<option value='".$aid."'>".$name."</option>";    

    
$i++;
    }

      
   
$article_content $article_content."</select>
</p>
  <p>Favorite Pet Bio: 
    <textarea name='about' cols='45' rows='4' id='about'>"
.$about."</textarea>Here is a bio for your pet, the maximum number of characters you can use is 200. You can write whatever you want but abide by the </a href='tos.php'>ToS</a> and do NOT post content that involves an advertisement, vulgar language, or any other acts that could get your account banned. BBC is NOT useable for this.
</p>
    <input name='act' type='hidden' id='act' value='moreprofile'>
</p>
  <p>
    <input type='submit' name='Submit' value='Submit Details'>
  </p>
</form>"
;


This will let you change your profile page. But wait! You're not done!

Now go open up accountpost.php, we need to actually have this work!
Go find:
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);

$website $_POST["website"];
$website secure($website);

$aim $_POST["aim"];
$aim secure($aim);

$yim $_POST["yim"];
$yim secure($yim);

$msn $_POST["msn"];
$msn secure($msn);

if(
$newmsgnotify != 1){
$newmsgnotify 0;
}

// Run update queries...

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

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

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

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

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

// All done!

$article_title $lang_changedsuccess_title;
$article_content $lang_changedsuccess;

And directly after it add:
PHP Code:
else if($act == "moreprofile"){

// We are changing the settings

$nickname $_POST["nickname"];
$nickname secure($nickname);

$gender $_POST["gender"];
$gender secure($gender);

$color $_POST["color"];
$color secure($color);

$profile $_POST["profile"];
$profile secure($profile);

$favpet $_POST["favpet"];
$favpet secure($favpet);

$about $_POST["about"];
$about secure($about);

// Run update queries...

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

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

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

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

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

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

// All done!

$article_title $lang_changedsuccess_title;
$article_content $lang_changedsuccess;

And now everything should edit properly! One last thing we need to do is display this information publicly! So now go open profile.php (the last step!)

Go find something like this:
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) {

    
$usersname=@mysql_result($result,$i,"username");
    
$usersgroup=@mysql_result($result,$i,"usergroup");
    
$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"); 
Now directly after this add in:
PHP Code:
    $bio=@mysql_result($result,$i,"profile");
    
$favcolor=@mysql_result($result,$i,"color");
    
$aboutfavpet=@mysql_result($result,$i,"about");
    
$favpetID=@mysql_result($result,$i,"favpet");
    
$gender=@mysql_result($result,$i,"gender");
    
$nickname=@mysql_result($result,$i,"nickname");

    if (
$favpetID == ""){
        
$favpet "None Selected";
    }
    else {
    
$favpet="<a href='/levelup.php?id=".$favpetID."' target='_blank'>
<img src='/siggy.php?id="
.$favpetID."' border=0></a>";
    }
    
    if (
$aboutfavpet == "" and $favpetID != ""){
        
$about "Click me! I'm hungry!";
    }
    else if (
$aboutfavpet == "" and $favpetID == ""){
        
$about "No Pet Selected";
    }
    else {
        
$about $aboutfavpet;
    } 
All done with that? Now you can arrange this however you see fit but somewhere in here:
PHP Code:
    <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><br>
    <
img src='templates/icons/title.gif'> <a href='messages.php?act=newpm&user=".$usersname."'>Send ".$usersname." Private Message</a><br><br><hr>
    <
br><b><u>".$usersname."'s Site Stats:</b></u><br><br>
    <b>Member Since:</b> ".$membersince."<br>
    <b>Pokemon Owned:</b> ".$numpets."<br>
    <b>Rank:</b> Ranks coming soon!<br><br> 
You need to add in:
PHP Code:
    Gender".$gender."<br>
    
Favorite Color".$favcolor."<br>
    
Nickname".$nickname."<br>
    
Bio: <br>
    
".$bio."<br>
    <
hr><br>
    <
h2>.:PokeSpotlight:.</h2><br>
    
".$favpet."<br>".$about."<br
Change the text obviously since PokeSpotlight and Pokemon Owned is probably not for your site X3 It's better to arrange this with HTML Tables, but I suck at those and don't want to bother with explaining that X3 But my site is set up with the info on the left and the Pet info on the right. Arrange how you like.

Now I think (hope) that's it! Have fun with your new features! :3
__________________


"I see now that the circumstances of one's birth are irrelevant; it is what you do with the gift of life that determines who you are."~Mewtwo
My Adoptables|Nuzlocke Webcomic

Last edited by PTGigi; 02-17-2011 at 02:49 PM. Reason: script change
Reply With Quote