5

I am developing a website where I need to send confirmation link to the user's e-mail account when he/she signs-up.

When user clicks this link then a field userEnable in database changes from "false" to "true".

How do I send a confirmation e-mail to a user when user clicks on the signup button.

When user clicks on this confirmation link then how would the field UserEnable change from "false" to "true"

I am using asp.net 4.0 with VB.NET as the language and SQL Server 2008 for my database.

gideon
  • 19,329
  • 11
  • 72
  • 113
Saman Zia
  • 147
  • 1
  • 3
  • 11
  • 4
    The fact that you want people here to just give you a full solution is not going to be taken well. Show what you have tried so far. – gideon Mar 20 '11 at 08:02

4 Answers4

4

The answer posted by nemke is good, but I do it slightly differently and I feel it is a bit more secure and protected against future changes. I create two extra fields for confirmation in each of my user records when they are created in the database.

Something like the following fields for each user:

userID: getUniqueUserID()
confirmed: false,
confirmCode: getRandomUUID()

The confirmCode is kept separate from the unique userID for each record and should only ever be used when the email is sent to the address used in registration. I then send a URL like the following:

http://example.com/activate?id=43d24b9ca73&c=16b4cf80-c59a-11e2-8b8b-0800200c9a66

You can then get the query fields server side and use the id in order look up the particular user record based on the unique userID, make sure the the c field matches confirmCode in the record, and then set the confirmed field to true and save the particular user's record in the database.

Cory Gross
  • 36,833
  • 17
  • 68
  • 80
  • I agree that guid should not be UserId, but an additional guid. It's better for security reasons. – nemke Sep 11 '13 at 09:49
4

First, you should create table User in database with a column like Active = false in database (1 bit database field type). Then, after user has created his account, you should send him an activation link with query string containing user activation guid. Something like:

Please activate your account at www.mysite.com?id=21EC2020-3AEA-1069-A2DD-08002B30309D

At confirmation page, you will check for this query like

var id = Response.QueryString["id"]
if (id!= null) userBL.ActivateUser(id);

ActivateUser() method would update field to true, and also send an email confirmation.

nemke
  • 2,440
  • 3
  • 37
  • 57
0

Users

ID | Username | Email | UserEnabled

to send E-mail check this.

When you receive the confirmation link, you do a lookup based on the Email field and the set its corresponding UserEnabled to true.

Ken D
  • 5,880
  • 2
  • 36
  • 58
0

If you are using the ASP.NET Built in Membership Controls you can use the

MailDefinition property of the CreateUserWizard Control

The MailDefinition property returns a reference to a group of properties that you use to define the format and content of the e-mail message that is sent to new users. Common settings include the subject line and the sender's return address.

Caspar Kleijne
  • 21,552
  • 13
  • 72
  • 102