Report and Warns will not dele

Posted on Thursday 17th July 2008 at 07:40 PM
UrbanTwitch
UrbanTwitch's Avatar
Yeah I got the repcp.php straight from tutorial but with little sucess the reports won't delete when I tell them to delete.

Here it repcp.php

PHP Code
  1. <?php include("/home/jsfdan/public_html/includes/vtop.php"); ?>
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  3. "https://www.w3.org/TR/html4/strict.dtd">
  4.  
  5. <html>
  6. <head>
  7. <title>Report Panel - sodaDome.com</title>
  8. <link rel="shortcut icon" href="https://sodadome.com/favicon.ico">
  9. <meta name="Description" content="About Me.">
  10. <meta name="Keywords" content="sodaplay, sodarace, soda ltd, physics, education, science, gravity, mass, friction, javascript_freek, dan jasnowski, sodaplay, sodarace, sodaconstructor, models, moovl, ed burton, soda">
  11.  
  12. <?php include("/home/jsfdan/public_html/temp2/includes/titleheader.php"); ?>
  13. </head>
  14.  
  15. <?php include("/home/jsfdan/public_html/temp2/includes/greenlinks.php"); ?>
  16.  
  17. <?php include("/home/jsfdan/public_html/temp2/includes/leftmenu.php"); ?>
  18.  
  19. <!-- START BODY CONTENT -->
  20.  
  21. <?php
  22. if(!isSet($logged['username']))
  23. {
  24. die("Damn...Username is not set.<br> Must be an error somewhere in the include codes.<br><i>Check vtop.php for session_start(); maybe?)</i>");
  25. }
  26. if(!$logged['username']){ //check logged user
  27. print "<h2>Error</h2>
  28. <p>
  29. You Are Not Logged In!
  30. </p>"; //nope
  31. }elseif(!$logged['username'] && $logged['userlevel'] < '4'){ //not an admin or mod
  32. print "<h2>Error</h2>
  33. <p>
  34. You Do Not Have Access to this Function.
  35. </p>"; //give error >:|
  36. }else{ //or they are :D
  37. switch($_GET['x']){ //make multiple pages
  38. default: //default
  39. $get_reps = mysql_query("SELECT * FROM `reps` ORDER BY `id` DESC"); //get all reports
  40. if(mysql_num_rows($get_reps) == 0){ //none >:(
  41. print "<h2>No Reports</h2>
  42. <p>
  43. There are No Reports in the Database.
  44. </p>"; //woohoo error!!
  45. }else{ //or not >)
  46. print "<table width="500">
  47. <tr>
  48. <td align="left" valign="middle">
  49. <b>User</b>
  50. </td>
  51. <td align="left" valign="middle">
  52. <b>Reported By</b>
  53. </td>
  54. <td align="left" valign="middle">
  55. <b>Reason</b>
  56. </td>
  57. <td align="left" valign="middle">
  58. <b>Date Sent</b>
  59. </td>
  60. <td align="center" valign="middle">
  61. <b>Options</b>
  62. </td>
  63. </tr>"; //table headers
  64. while($reps = mysql_fetch_array($get_reps)){ //make a loop for the reports to be shown
  65. print "<tr>
  66. <td align="left" valign="middle">
  67. $reps[username]
  68. </td>
  69. <td align="left" valign="middle">
  70. $reps[reported_by]
  71. </td>
  72. <td align="left" valign="middle">
  73. $reps[reason]
  74. </td>
  75. <td align="left" valign="middle">
  76. $reps[date]
  77. </td>
  78. <td align="center" valign="middle">
  79. <a href="repcp.php?x=warn&id=$reps[id]">Warn $reps[username]</a>&nbsp;||&nbsp;
  80. <a href="repcp.php?x=delete&id=$reps[id]">Delete Report</a>
  81. </td>
  82. </tr>"; //yay for data to be shown :)
  83. } //end the loop :(
  84. } //end the reports check
  85. break; //end the default page
  86. case 'warn': //haha i get to warn the dude >:)
  87. $id = (int) addslashes($_GET['id']); //make the ID Safe
  88. if(!$id){ //no id sucker!
  89. print "<h2>Error</h2>
  90. <p>
  91. No ID Selected
  92. </p>"; //haha you got an error
  93. }else{ //or not :(
  94. $check = mysql_query("SELECT * FROM `reps` WHERE `id` = '$id';"); //check to make sure
  95. if(mysql_num_rows($check) == 0){ //lol you still got an error >:)
  96. print "<h2>Error</h2>
  97. <p>
  98. Invalid ID Selected.
  99. </p>"; //give him/her what they came for!
  100. }else{ //or not...
  101. $array = mysql_fetch_array($check); //array the data
  102. if(!$_POST['warn']){ //warn form wasn't submitted
  103. print "<h2>Warn $array[username]</h2>
  104. <form method="post" action="$_SERVER[PHP_SELF]?x=warn&id=$id">
  105. <p>
  106. <label>Reason</label>
  107. <textarea rows="5" cols="25" name="reason"></textarea>
  108. <input type="submit" name="warn" value="Warn $array[username]">
  109. </p>
  110. </form>"; //give the reasoning form :)
  111. }else{ //chyea the form was submitted
  112. $reason = protect($_POST['reason']); //make the reason safe
  113. $date = date("m-d-y h:i A"); //the date
  114. $from = $logged['username']; //who warned
  115. if(empty($reason)){ //reason was empty
  116. print "<h2>Error</h2>
  117. <p>
  118. You Must Give A Reason
  119. </p>"; //lol you got an error
  120. }else{ //darn. your not.
  121. $insert = mysql_query("INSERT INTO `warns` (`user`,`reason`,`from`,`date`) VALUES ('$array[username]','$reason','$from','$date');"); //warn the user
  122. $delete = mysql_query("DELETE FROM `warns` WHERE `id` = '$id'"); //delete the report
  123. if(!mysql_error()){ //no mySQL Error
  124. print "<h2>Success</h2>
  125. <p>
  126. $array[user] Has Been Warned!
  127. </p>"; //yay they were warned!
  128. }else{ //or not
  129. print "<h2>Error</h2>
  130. <p>
  131. ".mysql_error()."
  132. </p>"; //HAHA YOU GOT AN ERROR
  133. } //end error check
  134. } //end empty form check
  135. } //end the form submit check
  136. } //end the verification check
  137. } //end the final check if id is there or not xD
  138. break;
  139. case 'delete': //the delete report page >:)
  140. $id = (int) addslashes($_GET['id']); //make the ID safe
  141. if(!$id){ //no id HAHA
  142. print "<h2>Error</h2>
  143. <p>
  144. No ID Selected
  145. </p>"; //lol you got an error
  146. }else{ //there was an id D:
  147. $check = mysql_query("SELECT * FROM `reps` WHERE `id` = '$id';"); //check DB for ID
  148. if(mysql_num_rows($check) == 0){ //haha not found
  149. print "<h2>Error</h2>
  150. <p>
  151. Invalid ID Selected
  152. </p>"; //invalid ID
  153. }else{ //its found :) :(
  154. $delete = !mysql_query("DELETE FROM `warns` WHERE `id` = '" . $id . "'");
  155. if(!mysql_error()){ //no error
  156. print "<h2>Success</h2>
  157. <p>
  158. Report MAYBE deleted
  159. </p>"; //yay!!
  160. }else{ //or not....
  161. print "<h2>Error</h2>
  162. <p>
  163. ".mysql_error()."
  164. </p>"; //you got an error
  165. } //end error check
  166. } //end verification check
  167. } //end first id check
  168. break; //end the page
  169. }//end the switch function
  170. } //end logged username check
  171. ?>
  172.  
  173.  
  174. <!-- END BODY CONTENT -->
  175.  
  176. <?php include("/home/jsfdan/public_html/temp2/includes/footer.php"); ?>
Posted on Thursday 17th July 2008 at 07:44 PM
UrbanTwitch
UrbanTwitch's Avatar
Also

-----------------------

[15:42:37] Wasim says:
hmm try replacing...
PHP Code
  1. $delete = !mysql_query("DELETE FROM `warns` WHERE `id` = '" . $id . "'");

with...
PHP Code
  1. $delete = mysql_query("DELETE FROM `warns` WHERE `id` = '".$id."'");


-------------------------

Didn't work
Posted on Thursday 17th July 2008 at 10:49 PM
UrbanTwitch
UrbanTwitch's Avatar
Nevermind, I fixed.
Login or register to respond to this forum topic.