Query fout? Of php fout?
ban functie:
Nu haal ik alle info van de users table, dan delete ik de row waar de username is, die gepost is.
Dan zet ik deze info in de banned_users table.
Unban: Ik doe het zelfde, maar nu andersom.
Het probleem is: waar het email moet staan, en ip, enzo, komt ook de username te staan.
Hier zijn de 2 functies
Code (php)
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
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
<?php // let niet op de php tags, tis alleen voor de coloring
function procBanUser(){
global $session, $database, $form;
/* Username error checking */
$subuser = $this->checkUsername("banuser");
$q = "SELECT * FROM ".TBL_USERS." WHERE username= '$subuser'";
$result = $database->query($q);
$userid = mysql_result($result,"userid");
$pass = mysql_result($result,"password");
$ulevel = mysql_result($result,"userlevel");
$email = mysql_result($result,"email");
$time = mysql_result($result,"timestamp");
$ip = mysql_result($result,"ip");
/* Errors exist, have user correct them */
if($form->num_errors > 0){
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->getErrorArray();
header("Location: ".$session->referrer);
}
/* Ban user from member system */
else{
$q = "DELETE FROM ".TBL_USERS." WHERE username = '$subuser'";
$database->query($q);
$q = "INSERT INTO ".TBL_BANNED_USERS." VALUES ('$subuser', $session->time, '$pass', '$userid', '$ulevel', '$email', '$time', '$ip')";
$database->query($q);
header("Location: ".$session->referrer);
}
}
/**Unban
*/
function procUnBanUser(){
global $session, $database, $form;
/* Username error checking */
$subuser = $this->checkBannedUsername("unbanuser");
/*Getting other data, needed for unban*/
$q = "SELECT * FROM ".TBL_BANNED_USERS." WHERE username= '$subuser'";
$result = $database->query($q);
$userid = mysql_result($result,"userid");
$pass = mysql_result($result,"password");
$ulevel = mysql_result($result,"userlevel");
$email = mysql_result($result,"email");
$time = mysql_result($result,"timestamp");
$ip = mysql_result($result,"ip");
/* Errors exist, have user correct them */
if($form->num_errors > 0){
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->getErrorArray();
header("Location: ".$session->referrer);
}
else{
$q = "INSERT INTO ".TBL_USERS." VALUES ('$subuser', '$password', '0', $ulevel, '$email', $time, '$ip')";
$database->query($q);
$q = "DELETE FROM ".TBL_BANNED_USERS." WHERE username = '$subuser'";
$database->query($q);
header("Location: ".$session->referrer);
}
}
?>
function procBanUser(){
global $session, $database, $form;
/* Username error checking */
$subuser = $this->checkUsername("banuser");
$q = "SELECT * FROM ".TBL_USERS." WHERE username= '$subuser'";
$result = $database->query($q);
$userid = mysql_result($result,"userid");
$pass = mysql_result($result,"password");
$ulevel = mysql_result($result,"userlevel");
$email = mysql_result($result,"email");
$time = mysql_result($result,"timestamp");
$ip = mysql_result($result,"ip");
/* Errors exist, have user correct them */
if($form->num_errors > 0){
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->getErrorArray();
header("Location: ".$session->referrer);
}
/* Ban user from member system */
else{
$q = "DELETE FROM ".TBL_USERS." WHERE username = '$subuser'";
$database->query($q);
$q = "INSERT INTO ".TBL_BANNED_USERS." VALUES ('$subuser', $session->time, '$pass', '$userid', '$ulevel', '$email', '$time', '$ip')";
$database->query($q);
header("Location: ".$session->referrer);
}
}
/**Unban
*/
function procUnBanUser(){
global $session, $database, $form;
/* Username error checking */
$subuser = $this->checkBannedUsername("unbanuser");
/*Getting other data, needed for unban*/
$q = "SELECT * FROM ".TBL_BANNED_USERS." WHERE username= '$subuser'";
$result = $database->query($q);
$userid = mysql_result($result,"userid");
$pass = mysql_result($result,"password");
$ulevel = mysql_result($result,"userlevel");
$email = mysql_result($result,"email");
$time = mysql_result($result,"timestamp");
$ip = mysql_result($result,"ip");
/* Errors exist, have user correct them */
if($form->num_errors > 0){
$_SESSION['value_array'] = $_POST;
$_SESSION['error_array'] = $form->getErrorArray();
header("Location: ".$session->referrer);
}
else{
$q = "INSERT INTO ".TBL_USERS." VALUES ('$subuser', '$password', '0', $ulevel, '$email', $time, '$ip')";
$database->query($q);
$q = "DELETE FROM ".TBL_BANNED_USERS." WHERE username = '$subuser'";
$database->query($q);
header("Location: ".$session->referrer);
}
}
?>
Gewijzigd op 01/01/1970 01:00:00 door Stefan Candan
Waarom ga je records verwijderen om ze later weer toe te voegen?? Dat geeft alleen maar problemen. Maak gewoon een tabel aan waarin je de users id opslaat en de tijd dat men banned is. Dan kun je via een simpele query controleren of men nog banned is of niet ;-).
Hmm, ja, zo kan het ook nog, bedankt voor de tip, kzal eens kijken als het lukt