0

when a new member is created , an registration confirmation email should be sent along with an activation code. once the user used the activation code. it shouldnt be valid anymore. I want to delete the activation code.

how to delete the activation code from database once its been used?

billstep
  • 89
  • 4
  • what's an `activation code`? what kind of database is `the database`? If you still need the activation codes later on, it may even be better not to delete them at all, but add a field that will let you flag them as inactive, or 'used' – Timothy Groote May 02 '11 at 14:27
  • i have edited my question.check it out – billstep May 02 '11 at 14:40

1 Answers1

0

Given the fact that many questions are still unanswered, this answer is a concept-answer.

It can't 'just work' like this, but it will give you an idea on how to handle this.

for this example, i'll assume you keep track of activation codes in a separate table of their own. (which i have named tblActivationCodes in this example).

Once the user 'activates', drop the corresponding activation code from the database table with a similar call :

this code will work only in the load event of a Page that takes activationCode as an inline request variable.

http://www.mysite.com/activate.aspx?activationCode=12345-678-90

string Code = Context.Request["activationCode"] as string;

// MAKE SURE TO PUT SOMETHING HERE
// THAT WILL PREVENT SQL INJECTION!

string Query = String.Format("DELETE FROM tblActivationCodes WHERE code='{0}';", Code );

Now, tell whatever database you're using, (you have not provided me with enough info for this) to execute that query.

Timothy Groote
  • 8,614
  • 26
  • 52