so as we all know, im working on a forum.
what i need is an email activation (not verification; activation). i know how to send the email already.
i need to figure out how to generate a random link (and also make that link actually exist on my server) and once that's done, i can figure the rest out myself.
email activation
Started by coolaid, May 01 2006 02:02 AM
9 replies to this topic
#1
Posted 01 May 2006 - 02:02 AM
#2
Posted 01 May 2006 - 02:11 AM
there are a different number of ways you could do this.
i would do it like this: have an activation ID (random and unique string) generated when the user submits the registration. In the DB you have a field where this id is stored, and another field where it simply says if the user is activated or not. In the email sent to the user he / she has a link like activate.php?email=bob@bob.com&id=jkbgjkbvafs87HHIBb. And on activate.php you have a query which updates the users table to make the user activated if the right email and id are given.
i would do it like this: have an activation ID (random and unique string) generated when the user submits the registration. In the DB you have a field where this id is stored, and another field where it simply says if the user is activated or not. In the email sent to the user he / she has a link like activate.php?email=bob@bob.com&id=jkbgjkbvafs87HHIBb. And on activate.php you have a query which updates the users table to make the user activated if the right email and id are given.
#3
Posted 01 May 2006 - 03:04 AM
ok, that sounds definetly do-able.
but how cani generate the random string? i never worked with creating random strings before..
*****
edit, nevermind, i found the perfect function, mt_rand()
i'll post back if i dont get it successfully working. thanks.
but how cani generate the random string? i never worked with creating random strings before..
*****
edit, nevermind, i found the perfect function, mt_rand()
i'll post back if i dont get it successfully working. thanks.
Edited by coolaid, 01 May 2006 - 03:10 AM.
#4
Posted 01 May 2006 - 04:06 AM
I thought about the same Deadly, to have a row in the database like this:
`activated` int default '0'
or something.
This tutorial might help.
`activated` int default '0'
or something.
This tutorial might help.
#5
Posted 01 May 2006 - 06:44 AM
What i did to create a random string is i just used MD5 on the user's username. Creates a big ass string
#6
Posted 01 May 2006 - 07:34 AM
Quote
What i did to create a random string is i just used MD5 on the user's username. Creates a big ass string 
not a bad idea, gives you the unique activation ID for the user.
#7
Posted 01 May 2006 - 01:04 PM
ok i got it working good.
i think mt_rand is better than md5'ing the username. because, if a user happens to download the forum (i might go public..) and figures it out, he can hack that pretty easy by just using his own script to figure out the hash of the username.
i think mt_rand is better than md5'ing the username. because, if a user happens to download the forum (i might go public..) and figures it out, he can hack that pretty easy by just using his own script to figure out the hash of the username.
#8
Posted 01 May 2006 - 06:42 PM
i dont think md5 is reversable if that is what you meant...
#9
Posted 01 May 2006 - 07:48 PM
well i dont knw that either.
but think of it like this. a viewr download the register page. finds the code that says 'the active key is md5($username)'.
all they would have to do is create a blank php page that with this code:
md5("theusernametheyinserted");
then copy pase the hash and get away with creating multiple / spam accounts. any novice viewer that wants to cause trouble woudl do that easy.
---------
what i ended up doing is generate a random number, get the md5 of that, then get a sub string of that hash.
but think of it like this. a viewr download the register page. finds the code that says 'the active key is md5($username)'.
all they would have to do is create a blank php page that with this code:
md5("theusernametheyinserted");
then copy pase the hash and get away with creating multiple / spam accounts. any novice viewer that wants to cause trouble woudl do that easy.
---------
what i ended up doing is generate a random number, get the md5 of that, then get a sub string of that hash.
#10
Posted 02 May 2006 - 04:58 AM
k i get your point now
------
What im still wondering, how can a script choose something random?
How can the function md_rand pick a random number / How can a computer pick a random number?? Does it use some kind of formula to pick a random number? then how come it picks another number evey time. A computer cant think by itself, so i figured it must use something like that. lol, it confuses me like hell.
i would love to see the code behind that function.
lol
------
What im still wondering, how can a script choose something random?
How can the function md_rand pick a random number / How can a computer pick a random number?? Does it use some kind of formula to pick a random number? then how come it picks another number evey time. A computer cant think by itself, so i figured it must use something like that. lol, it confuses me like hell.
i would love to see the code behind that function.
lol
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
