Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Guys,
Ive been trying to implement the confirmation/activation account by clicking the link on email after the user registered. Problem is after registering the user get the mail notification to activate the account but when user click the link it dint change anything on the database. Any suggestion will be much appreciated.Thanks



C#
//Activation link

private string GetUserID(string p)
{
    SqlCommand cmd = new SqlCommand("SELECT User_id From Auction_user_regist WHERE Email=@Email", con);
        cmd.Parameters.AddWithValue("@Email", tbxEmail.Text);
         if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            string User_id = Convert.ToString(cmd.ExecuteScalar());
            con.Close();
            cmd.Dispose();
            return User_id;
        }
    }


// is_approved code 

public partial class Account_is_approved : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnection"].ToString());
    SqlCommand cmd = new SqlCommand();
    string User_id,Email;

    protected void Page_Load(object sender, EventArgs e)
    {
           
if ((Request.QueryString["User_id"] != null) & (Request.QueryString["Email"] != null))
{
     User_id = Request.QueryString["User_id"];
     Email = Request.QueryString["Email"];
     SqlCommand cmd = new SqlCommand("UPDATE Auction_user_regist SET is_approved=1 WHERE User_id=@User_id AND Email=@Email", con);
     cmd.Parameters.AddWithValue("@User_id", User_id);
     cmd.Parameters.AddWithValue("@Email", Email);
     con.Open();
     cmd.ExecuteNonQuery();
     con.Close();
        }
    }
}
Posted
Updated 3-May-15 5:35am
v2
Comments
OriginalGriff 3-May-15 11:17am    
Why do you think a screenshot of the code is going to help anybody?
Copy it, paste it into your question, and use pre tags (or the **code** menu option) to preserve the formatting.

And then explain what you have looked at, what you have done, to try and fix this.

Use the "Improve question" widget to edit your question and provide better information.
Hi khayinso,

I think you accepted the answer and again rejected. If this is by mistake, please accept it again.

Thanks,
Tadit

1 solution

First of all, take OriginalGriff's advice and improve your question to add codes here instead of giving image links.

Let's come to your code now. According to your code, on the Page Load of Activation Page, it requires two QueryString parameters they are User_id and Email. So, your URL should include these.

URL may be like - www.somewebsite.com/Activation.aspx?User_id=1&Email=something@some.com

Note that I have not encoded, you should encode the URL while sending it to the User's Email.

Next, just click on the link and debug your code. See if it correctly executing or not. Also log exceptions, if possible.

But ideally, you should include these information in URL, instead just add some activation code or something through which you can identify the User. Refer - Send user Confirmation email after Registration with Activation Link in ASP.Net[^]
 
Share this answer
 
Comments
khayinso 3-May-15 12:53pm    
Thanks for the help.. ur refer link solved the problem
Great. Welcome. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900