Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 246
0 Users 3 Guests Online

User Rank On Profile

This is a pretty simple tutorial just got to add one or two lines of code and a new mySQL Table :P

First run this through PHPMyAdmin:
Code

CREATE TABLE `groups` (
`id` int(11) NOT NULL auto_increment,
`lvlnum` int(3) NOT NULL default '1',
`full_name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
INSERT INTO `groups` (`lvlnum`,`full_name`) VALUES ('1','Unverified Member');
INSERT INTO `groups` (`lvlnum`,`full_name`) VALUES ('2','Member');
INSERT INTO `groups` (`lvlnum`,`full_name`) VALUES ('4','Moderator');
INSERT INTO `groups` (`lvlnum`,`full_name`) VALUES ('6','Administrator');


Alright. On your members.php find:
Code

$user = mysql_fetch_array($getuser);


Add After:
Code

$user_rank = mysql_fetch_array(mysql_query("SELECT * FROM `groups` WHERE `lvlnum` = '$user[userlevel]';"));


Now Find:
Code

Email: $user[email]<br>


Add After:
Code

User Rank: $user_rank[full_name]<br>


That should be it. :P
ShadowMage
Author:
Views:
3658
Rating:
Posted on Thursday 14th August 2008 at 12:55 AM
UrbanTwitch
UrbanTwitch
PHP Code
1
2
3
4
5
6
7
8
9
10
if ($user[userlevel] == 6) {

echo "Rank: Administrator";
}elseif ($user[userlevel] == 4) {

echo "Rank: Moderator";
}elseif ($user[userlevel] == 2) {

echo "Rank: Moderator";
}


Thats the only way I see it jambomb.
Posted on Wednesday 13th August 2008 at 10:00 PM
jambomb
jambomb
how do i make it so it doesnt HAVE To be on members page.. ? coz it only works on members page
Posted on Wednesday 16th July 2008 at 11:39 AM
Dava
Dava
UrbanTwitch check your edits because i have this working same with every tutorial on this site apart from member pagination which im tryin to sort out
Posted on Tuesday 15th July 2008 at 07:44 PM
UrbanTwitch
UrbanTwitch
Does anyone else get this: Fatal error: Call to undefined function change_levels() in /home/jsfdan/public_html/members.php on line 33?
Posted on Tuesday 15th July 2008 at 06:01 PM
UrbanTwitch
UrbanTwitch
This doesn't work. :
Posted on Wednesday 11th June 2008 at 09:24 PM
SkillMaster
SkillMaster
Ah but in online.php you have included config.php what you need to do. is create a functions.php file and put all the function coding in there AND only include functions.php in the pages that you need.
Posted on Monday 9th June 2008 at 04:27 AM
Adam981
Adam981
haha! i fixed it, just place

PHP Code
1
2
3
4
5
6
7
8
9
10
<?php 
function change_levels($level){ //define the function 
$listed = array('2','4','6'); // define your levels 
// if you wish to add to this list just add '', between the quotes add the rank number. 
$changed = array('Member','Moderator','Admin'); //this is the changed rank name 
//Again if you wish to add to the like just add '', 
return str_replace($listed$changed$level); //replace the listed rank with the rank name 
//End the function 
?>


under where u would put

Code
$user_rank = change_levels($user[userlevel]); //change level
Posted on Sunday 8th June 2008 at 11:14 PM
Adam981
Adam981
Fatal error: Cannot redeclare change_levels() (previously declared in /home/crystal/public_html/config.php:26) in /home/crystal/public_html/config.php on line 32


include online.php doesnt have config..
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?  
session_start
(); //allows session 
include ('online.php');
$conn mysql_connect("localhost","xxx","xxx");  
mysql_select_db(xxx) or die(mysql_error());  

$logged MYSQL_QUERY("SELECT * FROM `members` WHERE `id` = '$_SESSION[id]' AND `password` = '$_SESSION[password]'");  
$logged mysql_fetch_array($logged);  

//some server details, don't edit! 
$host $_SERVER['HTTP_HOST']; 
$self $_SERVER['PHP_SELF']; 

//change this to your site name 
$sitename "My Site"

//Send emails or not (email activation). 1 = true, 0 = false 
$semail "0"


$sets mysql_query("SELECT * FROM site_stats WHERE `sid` = '1';");
$setting mysql_fetch_array($sets);
//get the info and let it be used all over the site :)


function change_levels($level){ //define the function 
$listed = array('2','4','6'); // define your levels 
// if you wish to add to this list just add '', between the quotes add the rank number. 
$changed = array('Member','Moderator','Admin'); //this is the changed rank name 
//Again if you wish to add to the like just add '', 
return str_replace($listed$changed$level); //replace the listed rank with the rank name 
//End the function 

 


?>
Posted on Friday 6th June 2008 at 06:48 AM
SkillMaster
SkillMaster
You are obviously using include();, therefore you have included config.php twice. Remove it from the top of this script.
Posted on Friday 6th June 2008 at 06:15 AM
zerocool
zerocool
i have the same error as Adam981