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

Change User Levels

Hey Everybody! I have made an tutorial on changing your user levels i used some of jamvinces2k tutorial but not really that much.

Now to get started.

First the requirements:
Php usersystem
PHP 4
MYSQL
A Brain
A text Editor

Now, it's time to start working if you fit those requirments


Make an file called changelevel.php
And put
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
<?
ob_start
(); //starts cookies
session_start();//starts sessions
include("config.php"); //includes the config file for all the database information
if ($logged[level] == 6) { //makes sure the user is an admin
if (!$_POST[update])
//what if it does
{
//ends function that is on top of this line
//echo starts an echo there on the line below
echo("<form method=\"POST\">
<font size=1>Username:
<input size=\"25\" type=\"text\" name=\"name\" value=\"Username\"><br><br>
Level:
<input size=\"25\" type=\"text\" name=\"level\" value=\"levelhere\">
<input size=\"25\" type=\"submit\" value=\"Submit\" name=\"update\">
</form>"
);
//ends the echo
}
else
{
//makes it different page like cases recommeneded to learn if else.
$usernamehtmlspecialchars(addslashes($_POST[name]));
$levelhtmlspecialchars(addslashes($_POST[level])); 
//posts it and uses safes.
echo ("$username has sucessfully changed levels");
//displays an echo to show it's done
$update mysql_query("Update members set level = '$level' where username = '$username'");
//inserts it all into the database
}
//ends an function
}
//ends an function
?>


Enjoy any support tell me below!
cyruswu
Author:
Views:
2338
Rating:
Posted on Saturday 3rd May 2008 at 03:40 AM
Adam98
Adam98
hmm when i load the page nothing shows up?
Posted on Sunday 6th May 2007 at 05:41 PM
ShadowMage
ShadowMage
To make this a bit safer so the user can not enter letters into the level field

find:
Code

$level= htmlspecialchars(addslashes($_POST[level]));


you can replace with:
Code

$level = (int) htmlspecialchars(addslashes($_POST[level]));


This should make sure that the text entered for level is a number instead of letters or other random text.
Posted on Sunday 6th May 2007 at 01:32 PM
cyruswu
cyruswu
Make an mysql row with online. But since i told you yeah. Please do not copy me.

And use the select to find the user's online where the row online says YES
Posted on Saturday 5th May 2007 at 06:32 PM
gbt91
gbt91
XD ok guys XD
can someone help me out?
i'm looking for a way to show current online users
Posted on Saturday 5th May 2007 at 12:21 PM
cyruswu
cyruswu
What Do You Don't understand. Have you heard of Copy and pasters.
Posted on Friday 4th May 2007 at 02:50 PM
ShadowMage
ShadowMage
its meant to stop copy and pasters o.o;
Posted on Friday 4th May 2007 at 02:37 PM
gbt91
gbt91
lol
the function safe didnt work when i tried it, i replaced it with
$username= htmlspecialchars(addslashes($_POST[name]));
$level= htmlspecialchars(addslashes($_POST[level]));
and it worked...
enough?
Posted on Thursday 3rd May 2007 at 09:06 PM
cyruswu
cyruswu
No! Admins don't update it at all. You can edit it all day if you want.

Also, please tell me the error.
Posted on Thursday 3rd May 2007 at 04:35 PM
gbt91
gbt91
lol, this script doesnt work instead of
$username = safe($_POST[name]);
$level = safe($_POST[level]);
put
$username= htmlspecialchars(addslashes($_POST[name]));
$level= htmlspecialchars(addslashes($_POST[level]));
that's the correct way to safe it lol :P
ask an admin to change it for you