Warn Users System Pt. 2

Posted on Saturday 9th June 2007 at 05:53 AM
MCP
MCP's Avatar
I tried pulling all the stops I knew of. So now I turn it over to you guys for a try.

Here is my code from repcp.php
PHP Code
  1. <?php
  2. session_start(); //allows session
  3. include "config.php";
  4. switch($_GET[x]){ // Make Links ?x=case
  5. default: // set default case
  6. if(!$logged[username] || $logged[userlevel] !== 6){ //check if they are logged in and an admin
  7. echo "<p class='error'>Sorry, but only Admins may view this page. Please go back!</p>"; //they are not
  8. }else{ //or if they are
  9. $get = mysql_query("SELECT * FROM reps") or die(mysql_error()); //get all reports
  10. $gnum = mysql_num_rows($get); //get how many there are
  11. if($gnum == 0){ //check if there are any
  12. echo "There are no reports to view"; //if not...
  13. }else{ // or if there are
  14. echo "There are currently $gnum reports to review"; //Yay there are some
  15. while($ec = mysql_fetch_array($get)){ //repeats the data
  16. echo "<table width='150' align='center'>
  17. <tr>
  18. <td width='150' align='center' valign='top'>
  19. <b>$ec[user]</b>
  20. &nbsp;<b>Reported By:</b>: $ec[by]
  21. </td>
  22. </tr>
  23. <tr>
  24. <td width='200' colspan='2' align='center' valign='top'>
  25. <p>$ec[reason]</p>
  26. </td>
  27. </tr>
  28. <tr>
  29. <td width='350' colspan='3' align='center' valign='top'>
  30. <b>Date Reported</b>: $ec[date]&nbsp;|&nbsp;<a href='repcp.php?x=warn&y=$ec[user]'>Warn User</a>&nbsp;|&nbsp;<a href='repcp.php?x=delete&id=$ec[id]'>Delete</a>
  31. </td>
  32. </tr>
  33. </table>"; //echo the report
  34. } //End: the while
  35. } //End: check if there are reports or not
  36. } //End: level check
  37. break; //end the default case
  38. case 'warn': //the warn area :)
  39. if(!$logged[username] || $logged[userlevel] !== 6){ //check if logged in and admin
  40. echo "<p class='error'>Sorry, but only Admins may view this page. Please go back!</p>"; //echo this
  41. }else{ //or do other things
  42. if(!$_GET[y]){ //check if theres a user selected
  43. echo "<p class='error'>No user selected</p>"; //if not
  44. }else{ //or do other things
  45. if(!$_POST[warn]){ //check if the form was submitted or not
  46. echo "<form method='post'>
  47. <b>Username</b>:
  48. <input type='text' name='user' value='$_GET[y]' readonly='readonly'><Br />
  49. <b>Warn Reason</b>:<Br />
  50. <textarea rows='5' cols='35' name='reason'></textarea>
  51. <input type='submit' name='warn' value='Warn $_GET[y]'>
  52. </form>"; //Echo The Form
  53. }else{ //the form was submitted...
  54. $user = strip_tags(stripslashes($_POST[user]));
  55. $reason = stripslashes(strip_tags($_POST[reason]));
  56. $date = date("l, F d, Y");
  57. mysql_query("INSERT INTO warnings (`user`,`reason`,`from`,`date`) VALUES ('$user','$reason','$logged[username]','$date')") or die(mysql_error()); //mysql query to insert or die
  58. echo "$user has been warned"; //Echo this if success
  59. } //End: check if form was submitted
  60. } //End: check if user is selected
  61. } //End: check if logged in and an admin
  62. break; //End warn case
  63. case 'delete': //delete case
  64. if(!$Logged[username] || $logged[userlevel] !== 6){ //check if logged in and an admin
  65. echo "<p class='error'>Sorry, but only Admins may view this page. Please go back!</p>"; //error
  66. }else{ //or do this
  67. if(!$_GET[id]){ //check if user/report was selected
  68. echo "<p class='error'>No report was selected to delete</p>"; //if not echo this
  69. }else{ //or do the following
  70. mysql_query("DELETE FROM reps WHERE id = '$_GET[id]'") or die(mysql_error()); //delete the report
  71. echo "Report Deleted"; //echo this
  72. } //End: check if id selected
  73. } //end: login and admin check
  74. break; //end delete case
  75. } //end switch and get
  76. ?>
Posted on Saturday 9th June 2007 at 05:55 AM
MCP
MCP's Avatar
The error I am having is no matter what I change on the code this appears.
"Sorry, but only Admins may view this page. Please go back!"

I am an admin. lol
Posted on Saturday 9th June 2007 at 11:28 PM
Diablosblizz
Diablosblizz's Avatar
PHP Code
  1. <?php
  2. session_start(); //allows session
  3. include "config.php";
  4. switch($_GET[x]){ // Make Links ?x=case
  5. default: // set default case
  6. if(!$logged[username] || $logged[userlevel] == !6){ //check if they are logged in and an admin
  7. echo "<p class='error'>Sorry, but only Admins may view this page. Please go back!</p>"; //they are not
  8. }else{ //or if they are
  9. $get = mysql_query("SELECT * FROM reps") or die(mysql_error()); //get all reports
  10. $gnum = mysql_num_rows($get); //get how many there are
  11. if($gnum == 0){ //check if there are any
  12. echo "There are no reports to view"; //if not...
  13. }else{ // or if there are
  14. echo "There are currently $gnum reports to review"; //Yay there are some
  15. while($ec = mysql_fetch_array($get)){ //repeats the data
  16. echo "<table width='150' align='center'>
  17. <tr>
  18. <td width='150' align='center' valign='top'>
  19. <b>$ec[user]</b>
  20. &nbsp;<b>Reported By:</b>: $ec[by]
  21. </td>
  22. </tr>
  23. <tr>
  24. <td width='200' colspan='2' align='center' valign='top'>
  25. <p>$ec[reason]</p>
  26. </td>
  27. </tr>
  28. <tr>
  29. <td width='350' colspan='3' align='center' valign='top'>
  30. <b>Date Reported</b>: $ec[date]&nbsp;|&nbsp;<a href='repcp.php?x=warn&y=$ec[user]'>Warn User</a>&nbsp;|&nbsp;<a href='repcp.php?x=delete&id=$ec[id]'>Delete</a>
  31. </td>
  32. </tr>
  33. </table>"; //echo the report
  34. } //End: the while
  35. } //End: check if there are reports or not
  36. } //End: level check
  37. break; //end the default case
  38. case 'warn': //the warn area :)
  39. if(!$logged[username] || $logged[userlevel] !== 6){ //check if logged in and admin
  40. echo "<p class='error'>Sorry, but only Admins may view this page. Please go back!</p>"; //echo this
  41. }else{ //or do other things
  42. if(!$_GET[y]){ //check if theres a user selected
  43. echo "<p class='error'>No user selected</p>"; //if not
  44. }else{ //or do other things
  45. if(!$_POST[warn]){ //check if the form was submitted or not
  46. echo "<form method='post'>
  47. <b>Username</b>:
  48. <input type='text' name='user' value='$_GET[y]' readonly='readonly'><Br />
  49. <b>Warn Reason</b>:<Br />
  50. <textarea rows='5' cols='35' name='reason'></textarea>
  51. <input type='submit' name='warn' value='Warn $_GET[y]'>
  52. </form>"; //Echo The Form
  53. }else{ //the form was submitted...
  54. $user = strip_tags(stripslashes($_POST[user]));
  55. $reason = stripslashes(strip_tags($_POST[reason]));
  56. $date = date("l, F d, Y");
  57. mysql_query("INSERT INTO warnings (`user`,`reason`,`from`,`date`) VALUES ('$user','$reason','$logged[username]','$date')") or die(mysql_error()); //mysql query to insert or die
  58. echo "$user has been warned"; //Echo this if success
  59. } //End: check if form was submitted
  60. } //End: check if user is selected
  61. } //End: check if logged in and an admin
  62. break; //End warn case
  63. case 'delete': //delete case
  64. if(!$Logged[username] || $logged[userlevel] !== 6){ //check if logged in and an admin
  65. echo "<p class='error'>Sorry, but only Admins may view this page. Please go back!</p>"; //error
  66. }else{ //or do this
  67. if(!$_GET[id]){ //check if user/report was selected
  68. echo "<p class='error'>No report was selected to delete</p>"; //if not echo this
  69. }else{ //or do the following
  70. mysql_query("DELETE FROM reps WHERE id = '$_GET[id]'") or die(mysql_error()); //delete the report
  71. echo "Report Deleted"; //echo this
  72. } //End: check if id selected
  73. } //end: login and admin check
  74. break; //end delete case
  75. } //end switch and get
  76. ?>


Works fine, I changed it though so use it.
Posted on Sunday 10th June 2007 at 12:43 AM
MCP
MCP's Avatar
Works now. Thanks.
Login or register to respond to this forum topic.