Gamenati
04-16-2003, 04:47 PM
hey,
FOA, i want to make a regristration where they sign up and an email is sent to them w/ instructions on how to active their accout, but if they dont sign up in 24 hours, it deletes from the table.
i was wondering how to do the deleting part.
secondly, how do you create a random string? like wcucwjhgcagcwuywuge
thanks in advance
jb4mt
04-16-2003, 04:52 PM
a) on a unix box depending on the level of access you have you can set up a "cron" job that runs at a certain interval, every hour for instance
b) you could just generate random numbers and then get the character associated with the ascii code
somebody else can either flesh these out or make other suggestions
trustedurl.com
04-16-2003, 04:52 PM
Originally posted by Gamenati
but if they dont sign up in 24 hours, it deletes from the table.
i was wondering how to do the deleting part.
Have a script run in a cron job that checks if some entries are too old...
Gamenati
04-16-2003, 04:59 PM
Originally posted by idologic_dh
Have a script run in a cron job that checks if some entries are too old...
how do i do that?
NicoV
04-16-2003, 05:09 PM
just make a script that checks whether entries are old and deletes them.
then go to your control panel and there should be a cron jobs option (in cpanel at least if it is enabled) then you can point it to your script and make it run every hour or something like that
digitok
04-17-2003, 02:30 AM
Hello again Gamenati :)
I have made you a small function to generate a
random string (since rand() can't use letters)...
Here it is...
<?
function rString($len) {
for ($ctr = 1; $ctr <= $len; $ctr++) {
$tmp .= chr(rand(97,122));
}
return $tmp;
}
?>
It can be used like this...
<?
echo(rString(15));
?>
That would echo something like "lwksudjemthspau"
Hope it helps.
ilyash
04-17-2003, 09:03 AM
if i were you i woudlnt use a random string...
it is possible for two strings to be the same...
instead u can maybe have a table in ure database that has
1 column .. make it be for example "1"
then every time you use the random string u append "null" to the db
(put the column on AUTO_INCREMENT)
then you can use that random string thhing that digitok was talking about...
just do:
RANDOMSTRING + (SQL GOES HERE TO RECEIVE # FROM DB)
and then do....
insert into (table name) values (null);
Hope it helps,
Saeven
04-17-2003, 02:47 PM
Hi.
Assuming that you want to store these registrations at send time, this is what you'll do, create a database 'registry' that has columns
email varchar(80) (pkey), registered int(1), stored timestamp(10)
So when the user clicks to register do something like this, have the email passed as a post variable to the page and (please forgive any syntactical mistakes I'm typing on my laptop:
if( isset( $_POST['email'] ) && strlen( $_POST['email']) ){
$connection = mysql_connect( 'hostname', 'db_user', 'db_pass');
mysql_select_db( $connection, 'db_name' );
/* can handle this the way you want, replace will renew the entry if the user hammers the submit a few times over */
mysql_query( "REPLACE INTO registry VALUES( '".$_POST['email']."', '0', NOW() )", $connection );
}
So now you have entries like
email@emailaddress.com, 0, 2003031530
So what you need to do is set a cronjob that perhaps runs every 12 hours,
0 0,12 * * * * *
that executes a php script that checks if the timestamp is more than 24 hours old, you can use NOW and DATE ADD or DATE SUB to figure it out, for example
DELETE FROM registry WHERE NOW() > DATE_ADD( timestamp, INTERVAL 24 hour );
And that'll purge the old entries.
Hope this helps.
There's a zillion date time functions out there which I'm sure the people here will be rather quick to throw at me hehe...they're all here:
http://www.mysql.com/doc/en/Date_and_time_functions.html
Cheers.