PDA

View Full Version : I need some help with this code please.


Parker Clack
06-23-2002, 02:13 AM
I have created a usergroupid of 14 for inactive users. I want to use a checkuser that if another person comes along with the same username and signs up it deletes the old username from the inactive list.

I have so far:

if ($checkuser=$DB_site->query_first("SELECT username FROM user WHERE usergroupid==14 AND (username='".addslashes(htmlspecialchars($username))."' OR username='".addslashes(eregi_replace("[^A-Za-z0-9]","",$username))."')")) {
DB_site->query("DELETE FROM user WHERE userid='bbuserinfo['userid']'");
}

which I know isn't right but is in the general ball park at least. :)

Thanks for any help.

Parker

Admin
06-23-2002, 05:51 AM
Try this:
$checkuser = $DB_site->query_first("
SELECT userid,username FROM user
WHERE usergroupid = 14 AND
(username = '".addslashes(htmlspecialchars($username))."' OR username = '".addslashes(eregi_replace("[^A-Za-z0-9]","",$username))."')
");
if ($checkuser) {
$DB_site->query("UPDATE post SET username='".addslashes($checkuser['username'])."',userid=0 WHERE userid='$checkuser[userid]'");
$DB_site->query("DELETE FROM user WHERE userid='$checkuser[userid]'");
$DB_site->query("DELETE FROM userfield WHERE userid='$checkuser[userid]'");
$DB_site->query("DELETE FROM access WHERE userid='$checkuser[userid]'");
$DB_site->query("DELETE FROM calendar_events WHERE userid='$checkuser[userid]'");
$DB_site->query("DELETE FROM customavatar WHERE userid='$checkuser[userid]'");
$DB_site->query("DELETE FROM moderator WHERE userid='$checkuser[userid]'");
$DB_site->query("DELETE FROM privatemessage WHERE userid='$checkuser[userid]'");
$DB_site->query("DELETE FROM subscribeforum WHERE userid='$checkuser[userid]'");
$DB_site->query("DELETE FROM subscribethread WHERE userid='$checkuser[userid]'");
$DB_site->query("DELETE FROM session WHERE userid='$checkuser[userid]'");
}

Parker Clack
06-23-2002, 06:25 AM
Chen:

Works like a charm!

Thanks again for helping me get this stuff done.

Parker