autolo

I would happy to know how to do this::

I have a register/login script

I have just added an activationprocess to it. when 0 account is not activated. when 1 account is activated. I want to give the user an activation link in an automaically generated email using php mail() function

in that i want to add a link like this

ActivateAccount?user=&code=[md5].

the activation code is created using the random function and is stored in the users table with the other info.

what i want:

When the user clicks on the link he/she msut be logged in and then a message opens that the account has been activated.

Can you please suggest an idea? I googled but it didn’t help much. How do i do it? Sessions?Cookies?

Since there’s the potential to leave the site after the registration, i’d use a cookie to store the login information. You’ll need to store the activation link in the the user’s table, so you’ll have something to compare it against. When the person clicks the link, run an update query to set the activation column to 1 and set the code to NULL.

Are you talking about sending a link in an email to the user so they can activate their account?
If so, you can change the line:
ActivateAccount?user=&code=[md5]

To something like:
<a href=‘www.yoursite.com/ActivateAccount.php?user=’$username’&code=’$password’>Click here to activate your account!

This would be sent in an email and link back to your site with a php file that would read the username and password (MD5 or whatever number) and would process the file and update the database. This will only work if the user can accept HTML emails. This is really not an issue in this day and age. Your “ActivateAccount” code would use $_GET to pull the two values needed and process the data. Then, it would send another email explaining how to log in and how to use your site.

Hope that helps!

Sponsor our Newsletter | Privacy Policy | Terms of Service