Admin Panel

Posted on Monday 4th June 2007 at 08:34 PM
SkillMaster
SkillMaster's Avatar
Are you sure your logged in?
Posted on Monday 4th June 2007 at 08:57 PM
SkillMaster
SkillMaster's Avatar
This code works it is tested.

PHP Code
  1. <?php
  2. session_start();
  3. include "config.php";
  4. if($logged[username] && $logged[userlevel] == 6)
  5. {
  6. switch($_GET[page])
  7. {
  8. default:
  9. $fetch = mysql_query("SELECT * FROM `members` ORDER BY username ASC");
  10. while($users = mysql_fetch_array($fetch))
  11. {
  12. echo ("<a href='?page=edit&username=$users[username]'>- $users[username]</a><br>");
  13. }
  14. break;
  15.  
  16. case 'edit':
  17.  
  18. $user = mysql_query("SELECT * FROM `members` where username = '$_GET[username]'");
  19. $users = mysql_fetch_array($user);
  20. echo ("
  21. <form method='POST'>
  22. <table width='100%'>
  23. <tr>
  24. <td align='right' width='25%'>
  25. User Level</td>
  26. <td align='left'>
  27. <select name='level'>
  28. <option value='2'>User</option>
  29. <option value='4'>Mod</option>
  30. <option value='6'>Admin</option>
  31. </select> </td>
  32. </tr>
  33. <tr>
  34. <td align='right' width='25%'>
  35. Email</td>
  36. <td align='left'>
  37. <input type='text' size='25' maxlength='25' name='email' value='$users[email]'></td>
  38. </tr>
  39. <tr>
  40. <td align='right' width='25%'>Location</td>
  41. <td align='left'>
  42. <input size='25' name='location' value='$users[location]'></td>
  43. </tr>
  44. <tr>
  45. <td align='right' width='25%'>Age</td>
  46. <td align='left'>
  47. <input size='25' name='age' value='$users[age]'></td>
  48. </tr>
  49. <tr>
  50. <td align='center'></td>
  51. <td align='left'>
  52. <input type='hidden' value='$_GET[username]' name='username'>
  53. <input type='submit' name='submit' value='Update'></td>
  54. </tr>
  55. </table>
  56. </form>
  57. ");
  58. if($_POST[submit])
  59. {
  60. $username = htmlspecialchars($_POST[username]);
  61. $email = htmlspecialchars($_POST[email]);
  62. $age = htmlspecialchars($_POST[age]);
  63. $location = htmlspecialchars($_POST[location]);
  64. $level = htmlspecialchars($_POST[level]);
  65.  
  66. $update = mysql_query("UPDATE `members` SET `location` = '$location', `age` = '$age', `level` = '$level', `email` = '$email' WHERE `username` = '$username'");
  67. echo ("Thank you $logged[username], $members profile was updated!");
  68. }
  69. break;
  70. }
  71. }
  72. else
  73. {
  74. echo ("Sorry, but only Admins may view this page. Please go back!");
  75. }
  76. ?>
Posted on Monday 4th June 2007 at 10:18 PM
gbt91
gbt91's Avatar
gonna give you 5000 euros if this dooesn't works
PHP Code
  1. if ($logged[userlevel] == 6 OR $logged[userlevel] == 6) { //makes sure the user is an admin

I don't know why but after i define the level twice the code works xD
That's Just The Drill
Posted on Monday 4th June 2007 at 10:21 PM
Diablosblizz
Diablosblizz's Avatar
if ($logged[userlevel] == 6 OR $logged[userlevel] == 6)

You made it the exact same thing twice. Whats the point of that?
Posted on Tuesday 5th June 2007 at 12:09 AM
MCP
MCP's Avatar
YESSSSSS! Finally. The one you posted Skillmaster is working for me. WAHA! THANKS!
Posted on Tuesday 5th June 2007 at 05:33 AM
SkillMaster
SkillMaster's Avatar
do i get 5000 euros? LOL!
Posted on Tuesday 5th June 2007 at 03:39 PM
MCP
MCP's Avatar
Do you live in Europe?

Ok PayPal email please.
Posted on Tuesday 5th June 2007 at 07:33 PM
SkillMaster
SkillMaster's Avatar
No I live in Australia it should auto convert.
Posted on Tuesday 5th June 2007 at 08:39 PM
MCP
MCP's Avatar
lol I was kidding.
Posted on Tuesday 5th June 2007 at 08:56 PM
Login or register to respond to this forum topic.