When someone registers, store a random string in a mysql database along with their username then send them the email to tell them to goto activate.php?activationkey=[The random string here]&user=$username
Then in activation.php it should be something like this:
connect to db
select a table
select from users where username = '$username'
then umm...
Check whether the username matches the activation key