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


How can I check...





Diablosblizz
If 15 days have gone by. I have created a user system, and I want the ability to check if the user has verified their "activation code." (So I don't get people spamming up my user system).

I was thinking I can take the date stored in the MySQL database and minus it from the current date or something? I'm not too familiar with date and time in PHP, other than just showing it.

So, does anybody know if I can do this, and to make a "cron job" to email users everyday (if needed) saying that they must activate their account?

Also, keep in mind that I need the date to be exactly 15 days.

Kind regards!

Oh, and happy 700th post to me!! Very HappyVery Happy Applause Applause
rvec
it's all possible, although I wouldn't send the user an email each day but more like once a week or maybe twice.

If you could give me the date format used in the database I could write you something.



And may there be 700 more Very Happy
Diablosblizz
Yeah I don't want it to send everyday, but when it does send it updates the time to the current date and time and then sends it during the next 15 days. If the user doesn't reply back to the email within 3 emails then the account will be deleted.

I will try to Google it later on today.
rvec
the you could add a new column to the database which counts how many reminders a user has had. Run a script in cron twice a week to remind all users who need a reminder and if it is the 3th reminder you delete the user.
Diablosblizz
That's almost what I was thinking. Except, I don't want to bother the users everyday, more or less every week. So, for example, if it's their first they may get a email something like this:

"Please activate your account! This is your first warning ..."

Then a week later, their second warning:

"Second warning, please activate your account! ..."

Then a week later, their third and last warning:

"Final warning, your account is at risk ..."

Then a day after that it will delete their account. Though of course the cron job will have to be ran every day to check how many members are unactive. But, this does worry me. Without a doubt people will register with fake email address, and that will return it to the sender (AKA my default email account). So I was wondering if I could make a script that checks if the email is valid before sending it.

I will get looking soon, I still must finish the member system first! Oh, and if you have any time could you look at my other post? (It's in HTML) Thanks!

Kind regards!
rvec
i'd suggest checking if the mail is valid (something@something.something) before accepting the user. That's about all you can do, and if you use some kind of verification to make sure it's not a bot I doubt you'll get a lot of invalid mails.

Also I'd just use one script and let it run each week instead of running it daily. It would make it a bit easier to script because you wouldn't have to worry about how long ago you last reminded a user (always a week ago or not at all).

A daily script is a bit harder but also possible. And it has the huge advantage of being more dynamic. You could make a setting in your admin panel to determine how often and when the user should be reminded.
Diablosblizz
I am still confused on how to do it. I read the post by polly-gone but it didn't make much sense. Correct me if I am wrong, but this is how I see it:

You get the registered time in the MySQL database (let's say 3:10). You get the current server time (let's say 5:30). Then you would go:

Code:
<?php
$date("whatever here");
$registerdate = mysql_query("yada..yada...yada");
$total = $registerdate - $date;
if($total <= 0) {
echo "Blah blah - send email NOW!";
} else {
}
?>


So basically, if the time is equal to 0, or below, it will email the user?
rvec
Code:
$total = $registerdate - $date;
if($total <= 0) {

the user registers always before you run the script or you wouldn't have a record of him. So registerdate is always smaller than the date now. Which would mean total is always smaller than 0 or the same as 0.

What I did for polly-gone:
Code:
$hours = 48; //this is the time in hours which the users have to complete their registration


$time = mktime();// this is the time now

$deadline = $time - mktime($hours, 0, 0, 0, 0, 0);//the time now minus the number of hours set in $hours, so $deadline is 48 hours ago here.

$query = "DELETE FROM marketplace_users WHERE user_verify != '0000000000000000' AND user_added < '$deadline'";// delete the users who have not yet verified (0000...) and who have been added to the database before the deadline.

mysql_query($query) or die("Error in Query: $query. " . mysql_error());
Diablosblizz
Quote:
the user registers always before you run the script or you wouldn't have a record of him. So registerdate is always smaller than the date now. Which would mean total is always smaller than 0 or the same as 0.


So would that just reverse the $total variable because registerdate is lower? Also, the users are set in a "not verified" table, separating the registered and verified users from the not verified users.
rvec
could you show me the database structure like nick did?
Quote:
+--------------------------------------------------------------+
| user_id | user_name | user_verify | user_added |
+--------------------------------------------------------------+
| 1 | Bob | 00000000 | 20080330155031 |
+--------------------------------------------------------------+
| 2 | Bill | 1a2b3c4d | 20080405155031 |
+--------------------------------------------------------------+
| 3 | Jim | ghijklmno | 20080205155031 |
+--------------------------------------------------------------+


Then I'll write you a simple code you could use.
Diablosblizz
So you understand it, I'll use the same format as well. Wink

+--------------------------------------------------------------+
| id | username | code | email | datereg
+--------------------------------------------------------------+
| 1 | Bob | RBVUSE3kc1Lf6T7q | email@whatever.com | 05282008
+--------------------------------------------------------------+
| 2 | Bill | RBVUSE3kc1Lf6T7q | email@whatever.com | 07292008
+--------------------------------------------------------------+
| 3 | Jim | RBVUSE3kc1Lf6T7q | email@whatever.com | 07292008
+--------------------------------------------------------------+

*NOTE: datereg is in mm/dd/yyyy format.

Hope that makes more sense for you. Thanks! Kind Regards.
rvec
I tried a bit but I can't figure out how to solve it with that date format. Unless I get all the rows and compare it in php I have no clue, and I think you should change your format to one of teh ones supported by mysql.
YYYY-MM-DD
YYYY-MM-DD HH:MM:SS
or YYYYMMDDHHMMSS

Or you could use the Unix timestamp made with time().
Diablosblizz
So it's impossible to do it with DDMMYYYY? If you need to change it that's fine.
AftershockVibe
Diablosblizz wrote:
So it's impossible to do it with DDMMYYYY? If you need to change it that's fine.


It's not strictly impossible, just a really, really bad idea. You could use MySQL string manipulation functions to rearrange into something useful but why bother when you could just store it in another way to begin with.

The reason why DDMMYYYY (and the american MMDDYYYY) is not a nice format to store things in is because they can't be ordered easily because numerically the year is given the least significant digits in the number
Code:
20081212
20080101
20070101

Gives the dates in order when ordered numerically from highest to lowest (or vice versa). You can't do this with DDMMYYYY.

Having said that, please use a datatype for representing dates properly like timestamp or, if you must, then store as strings, then convert when you are comparing.

For the love of Jeebus, do not store the above format as an integer - it's begging for trouble.


Cool
Diablosblizz
I am not quite understanding. What you are saying is that I must change the format to something like YYYYMMDD - leaving year as the last, due to it not changing often and then month as it changes sometimes and day changing well everyday?
rvec
Diablosblizz wrote:
I am not quite understanding. What you are saying is that I must change the format to something like YYYYMMDD - leaving year as the last, due to it not changing often and then month as it changes sometimes and day changing well everyday?

Yeah and even better use the mysql date format (column type) which makes it easier to compare dates.
Afaceinthematrix
this is what i would do... when they sign up, have to rows in the user table of your mysql... one is simply a letter, y or n for verification... the default will be n and when they verify, have it update to y... then have another for dayssincesignup, and have the default be 0... then set up a cron... once a day, have it add 1 to the number in dayssincesignup of every user where verification = n... then have it delete everyone with a dayssincesignup = 15.... easy...
Related topics
Some bands to check out.
check box validation
Check out Freaks and Geeks
I just got me a com domain for my site check it out !
Accelerando RULES, you've got to check it out.
my site check it out and give feedback
bandwidth check.
How to check webmail ?
Admins please check out the games section..
I was bored so I Photoshopped this. Check it out.
check us out
My Photoblog - check this out
Your favourite book (official)
Anyone into Punk should check out...
Check My site Out
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.