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. ob_start(); //starts cookies
  3. session_start();//starts sessions
  4. include("config.php"); //includes the config file for all the database information
  5. if ($logged[level] == 6) { //makes sure the user is an admin
  6. if (!$_POST[update])
  7. //what if it does
  8. {
  9. //ends function that is on top of this line
  10. //echo starts an echo there on the line below
  11. echo("<form method=\"POST\">
  12. <font size=1>Username:
  13. <input size=\"25\" type=\"text\" name=\"name\" value=\"Username\"><br><br>
  14. Level:
  15. <input size=\"25\" type=\"text\" name=\"level\" value=\"levelhere\">
  16. <input size=\"25\" type=\"submit\" value=\"Submit\" name=\"update\">
  17. </form>");
  18. //ends the echo
  19. }
  20. else
  21. {
  22. //makes it different page like cases recommeneded to learn if else.
  23. $username= htmlspecialchars(addslashes($_POST[name]));
  24. $level= htmlspecialchars(addslashes($_POST[level]));
  25. //posts it and uses safes.
  26. echo ("$username has sucessfully changed levels");
  27. //displays an echo to show it's done
  28. $update = mysql_query("Update members set level = '$level' where username = '$username'");
  29. //inserts it all into the database
  30. }
  31. //ends an function
  32. }
  33. //ends an function
  34. ?>


Enjoy any support tell me below!
cyruswu's Avatar
Author:
Views:
2,589
Rating:
Posted on Saturday 3rd May 2008 at 03:40 AM
Adam98
Adam98's Avatar
hmm when i load the page nothing shows up?
Posted on Sunday 6th May 2007 at 05:41 PM
ShadowMage
ShadowMage's Avatar
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's Avatar
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's Avatar
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's Avatar
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's Avatar
its meant to stop copy and pasters o.o;
Posted on Friday 4th May 2007 at 02:37 PM
gbt91
gbt91's Avatar
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's Avatar
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's Avatar
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