Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 509
0 Users 6 Guests Online
Forum Index » PHP + MySQL » Report and Warns will not dele
Posted on Thursday 17th July 2008 at 07:40 PM
UrbanTwitch
templates/default/images/noavatar.png's Avatar
Senior Member
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
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php include("/home/jsfdan/public_html/includes/vtop.php"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>Report Panel - sodaDome.com</title>
<link rel="shortcut icon" href="http://sodadome.com/favicon.ico">
<meta name="Description" content="About Me.">
<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">

<?php include("/home/jsfdan/public_html/temp2/includes/titleheader.php"); ?>
</head>

<?php include("/home/jsfdan/public_html/temp2/includes/greenlinks.php"); ?>

<?php include("/home/jsfdan/public_html/temp2/includes/leftmenu.php"); ?>

<!-- START BODY CONTENT -->

<?php
if(!isSet($logged['username']))
{
    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>");
}
if(!
$logged['username']){ //check logged user
    
print "<h2>Error</h2>
    <p>
    You Are Not Logged In!
    </p>"
//nope
}elseif(!$logged['username'] && $logged['userlevel'] < '4'){ //not an admin or mod
    
print "<h2>Error</h2>
    <p>
    You Do Not Have Access to this Function.
    </p>"
//give error >:|
}else{ //or they are :D
    
switch($_GET['x']){ //make multiple pages
        
default: //default
            
$get_reps mysql_query("SELECT * FROM `reps` ORDER BY `id` DESC"); //get all reports
            
if(mysql_num_rows($get_reps) == 0){ //none >:(
                
print "<h2>No Reports</h2>
                <p>
                There are No Reports in the Database.
                </p>"
//woohoo error!!
            
}else{ //or not >)
                
print "<table width=\"500\">
                <tr>
                <td align=\"left\" valign=\"middle\">
                <b>User</b>
                </td>
                <td align=\"left\" valign=\"middle\">
                <b>Reported By</b>
                </td>
                <td align=\"left\" valign=\"middle\">
                <b>Reason</b>
                </td>
                <td align=\"left\" valign=\"middle\">
                <b>Date Sent</b>
                </td>
                <td align=\"center\" valign=\"middle\">
                <b>Options</b>
                </td>
                </tr>"
//table headers
                
while($reps mysql_fetch_array($get_reps)){ //make a loop for the reports to be shown
                    
print "<tr>
                    <td align=\"left\" valign=\"middle\">
                    
$reps[username]
                    </td>
                    <td align=\"left\" valign=\"middle\">
                    
$reps[reported_by]
                    </td>
                    <td align=\"left\" valign=\"middle\">
                    
$reps[reason]
                    </td>
                    <td align=\"left\" valign=\"middle\">
                    
$reps[date]
                    </td>
                    <td align=\"center\" valign=\"middle\">
                    <a href=\"repcp.php?x=warn&id=
$reps[id]\">Warn $reps[username]</a>&nbsp;||&nbsp;
                    <a href=\"repcp.php?x=delete&id=
$reps[id]\">Delete Report</a>
                    </td>
                    </tr>"
//yay for data to be shown :)
                
//end the loop :(
            
//end the reports check
            
break; //end the default page
        
case 'warn'//haha i get to warn the dude >:)
            
$id = (int) addslashes($_GET['id']); //make the ID Safe
            
if(!$id){ //no id sucker!
                
print "<h2>Error</h2>
                <p>
                No ID Selected
                </p>"
//haha you got an error
            
}else{ //or not :(
                
$check mysql_query("SELECT * FROM `reps` WHERE `id` = '$id';"); //check to make sure
                
if(mysql_num_rows($check) == 0){ //lol you still got an error >:)
                    
print "<h2>Error</h2>
                    <p>
                    Invalid ID Selected.
                    </p>"
//give him/her what they came for!
                
}else{ //or not...
                    
$array mysql_fetch_array($check); //array the data
                    
if(!$_POST['warn']){ //warn form wasn't submitted
                        
print "<h2>Warn $array[username]</h2>
                        <form method=\"post\" action=\"
$_SERVER[PHP_SELF]?x=warn&id=$id\">
                        <p>
                        <label>Reason</label>
                        <textarea rows=\"5\" cols=\"25\" name=\"reason\"></textarea>
                        <input type=\"submit\" name=\"warn\" value=\"Warn 
$array[username]\">
                        </p>
                        </form>"
//give the reasoning form :)
                    
}else{ //chyea the form was submitted
                        
$reason protect($_POST['reason']); //make the reason safe
                        
$date date("m-d-y h:i A"); //the date
                        
$from $logged['username']; //who warned
                        
if(empty($reason)){ //reason was empty
                            
print "<h2>Error</h2>
                            <p>
                            You Must Give A Reason
                            </p>"
//lol you got an error
                        
}else{ //darn. your not.
                            
$insert mysql_query("INSERT INTO `warns` (`user`,`reason`,`from`,`date`) VALUES ('$array[username]','$reason','$from','$date');"); //warn the user
                            
$delete mysql_query("DELETE FROM `warns` WHERE `id` = '$id'"); //delete the report
                            
if(!mysql_error()){ //no mySQL Error
                                
print "<h2>Success</h2>
                                <p>
                                
$array[user] Has Been Warned!
                                </p>"
//yay they were warned!
                            
}else{ //or not
                                
print "<h2>Error</h2>
                                <p>
                                "
.mysql_error()."
                                </p>"
//HAHA YOU GOT AN ERROR
                            
//end error check
                        
//end empty form check
                    
//end the form submit check
                
//end the verification check
            
//end the final check if id is there or not xD
            
break;
        case 
'delete'//the delete report page >:)
            
$id = (int) addslashes($_GET['id']); //make the ID safe
            
if(!$id){ //no id HAHA
                
print "<h2>Error</h2>
                <p>
                No ID Selected
                </p>"
//lol you got an error
            
}else{ //there was an id D:
                
$check mysql_query("SELECT * FROM `reps` WHERE `id` = '$id';"); //check DB for ID
                
if(mysql_num_rows($check) == 0){ //haha not found
                    
print "<h2>Error</h2>
                    <p>
                    Invalid ID Selected
                    </p>"
//invalid ID
                
}else{ //its found :) :(
                     
$delete = !mysql_query("DELETE FROM `warns` WHERE `id` = '" $id "'");
                    if(!
mysql_error()){ //no error
                        
print "<h2>Success</h2>
                        <p>
                        Report MAYBE deleted
                        </p>"
//yay!!
                    
}else{ //or not....
                        
print "<h2>Error</h2>
                        <p>
                        "
.mysql_error()."
                        </p>"
//you got an error
                    
//end error check
                
//end verification check
            
//end first id check
            
break; //end the page
    
}//end the switch function
//end logged username check
?>


<!-- END BODY CONTENT -->

<?php include("/home/jsfdan/public_html/temp2/includes/footer.php"); ?>
Posted on Thursday 17th July 2008 at 07:44 PM
UrbanTwitch
templates/default/images/noavatar.png's Avatar
Senior Member
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
templates/default/images/noavatar.png's Avatar
Senior Member
Nevermind, I fixed.