Question

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?

No correct solution

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top