FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Deleting unverified users... I AM CONFUZLED!





polly-gone
I want to create a script that will delete all users that have gone 48 hours without clicking on the confirmation link in their email. Why won't this work? It deletes all unconfirmed users.

Code:

$time = mktime();
$deadline = $time - mktime(50, 0, 0, 0, 0, 0);
$query = "DELETE FROM marketplace_users WHERE user_verify != '0000000000000000' AND user_added > '$deadline'";
$result = mysql_query($query) or die("Error in Query: $query. " . mysql_error());


-Nick Smile Smile Smile
kv
What is the current behavior? Does it delete all users or none? and what is the user_added? I guess it is updated with current time stamp when user registers and when user verifies.
rvec
Code:
$time = mktime();
$deadline = $time - mktime(50, 0, 0, 0, 0, 0);
$query = "DELETE FROM marketplace_users WHERE user_verify != '0000000000000000' AND user_added > '$deadline'";
$result = mysql_query($query) or die("Error in Query: $query. " . mysql_error());

I always use time() instead of mktime() but that shouldn't be a problem. So instead of your 2 first lines I'd use this:
$deadline = time() + ( 60 * 60 * 50 );
But if you want to see what happend >48 hours ago and delete those you need to change that 50 to 48.

And if a user verifies you set the 'user_verify' column to '0000000000000000' Confused If you set it to a timestamp and 0000000000000000 is the default value you shouldn't put that ! there.

user_added > '$deadline' means the user is added after the time set in $deadline. I think you want that the other way around.

The code you posted will delete all users that ARE verified within the last 50 hours. Better change it Wink
polly-gone
No. The string of zeros is what happens when a user gets verifed. When they aren't, a verification code is there and they have to go to register?confirm='1234567890123456'

Wait.... but how would adding to time solve my problem?

Thanks though, that help
-Nick Smile Smile Smile
polly-gone
Okay new question.... for this script, what format should my time in my database be?

-Nick Smile Wink Smile
rvec
if it's only a string of 00 how can you see when the user registered? Probably another field.

I'd go for linux timestamp
polly-gone
Here is how this part of the db is set up: I excluded non-essential parts from this post.

+--------------------------------------------------------------+
| user_id | user_name | user_verify | user_added |
+--------------------------------------------------------------+
| 1 | Bob | 00000000 | 20080330155031 |
+--------------------------------------------------------------+
| 2 | Bill | 1a2b3c4d | 20080405155031 |
+--------------------------------------------------------------+
| 3 | Jim | ghijklmno | 20080205155031 |
+--------------------------------------------------------------+

See, user 1, Bob, has zeros as his verify code so we know he has verified his email.

User 2, Bill, has a verify code, but his added date is today, April 5th, so he still has one more day to go to marketplace.tsljournal.com/register.php?confirm=1a2b3c4d, which would then set his code to 0.

User 3, Jim, still has a verify code meaning he has not gone to his verify link, marketplace.tsljournal.com/register.php?confirm=ghijklmno, and his added date is almost 2 months ago, so I want him to be deleted from the user database.

Could someone post the exactly code to do that sans database info cuz I can fill that in myself.

Thanks,
-Nick Smile Smile Wink
rvec
Code:

$hours = 48; //this is the time in hours which the users have to complete their registration

$time = mktime();
$deadline = $time - mktime($hours, 0, 0, 0, 0, 0);
$query = "DELETE FROM marketplace_users WHERE user_verify != '0000000000000000' AND user_added < '$deadline'";
mysql_query($query) or die("Error in Query: $query. " . mysql_error());

I think that should delete users who have not completed their registration and have registered more than $hours (48 here) hours ago.

If this doesn't work it's probably because of this line:
mktime($hours, 0, 0, 0, 0, 0);
But I think it should work.
polly-gone
Grr.... It isn't working. If I put a plain PHP script on a page and go to that script in my browser, it should run the script, right?

-Nick Question Question Question
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.