Jump to content

account activation link sent by email

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
jimiwa

jimiwa

    Newbie

  • Members
  • PipPip
  • 14 posts
I'm not new to programming, but I am new to web programming. I'm
wanting to do a website with forums, chats, and other features and
I'm wondering how to have an activation link.

I'm not wondering how to send the email specifically, but I want to know
how do I handle the part where someone clicks in the email to go to
activate the new account and the account gets activated when they
go to that page? I'm assuming this means I have special parameters
like when you go to a page and there's a ? after the name of the file
and certain parameters. I don't know what this is called so I couldn't
google it to find out. Anyways, I'm guessing I'd need to create a special
code in my database for the new user and when they click in their email
it directs them to the web site using the code as a parameter. How is this done? Thanks.

#2
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
When I did this my table structure looked like this:

Quote

id, name, email, password, activated, code
When they register fill them all out, activated would be default at 0, if it's 1 they are activated. The code needs to be something that you make up, but it needs to be long enough to be unique. You might md5 the username/email and the current time or something.

Email them the code with a link:
site.com/activate.php?code=123456code&email=user@site.com

Validate that the code matches the email address and then switch the "activate" to 1 if it matches up

Quote

UPDATE `users` SET `activated`=0 WHERE `email`='$email' && `code`='$code'