Activation code, how would I make a different one each time

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

Activation code, how would I make a different one each time

Post by Mythic Fr0st »

So, on my game, you signup, you get an e-mail, however, I want it so you get an activation code, and then enter it into a box, and your registered...

So, they signup, they get the activation code

they type it in, and it finishes the signup...

so, how would I tell if its there first time logging in? and if the activation code is right O_O (and how would I make the activation code lolz, I was fiddling around with the uniqid() thing, that creates a unique id... but im not sure
( and how would I make sure its different each time
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

so, how would I tell if its there first time logging in?
Have a separate account confirmation page.
and if the activation code is right O_O
Store the code in the db and match it to the user's email address
and how would I make the activation code
Keep your salt hidden:

Code: Select all

$salt = 'somestring';
$uniqueId = md5($salt . time());
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

another idea is to combine the username with the MySQL InsertRowId in an MD5 hash.

The insertRowId would be private to your database (therefore difficult or impossible to guess from the outside) and it gives you don't have to cache the MD5 hash, since you can recreate it on the fly.

hehe - cache the hash.... I need to get out more :-(

Kieran
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Yep, better.
Post Reply