protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
//验证码是Session["repwd_Verification_code"]
if (TextBox3.Text.ToUpper().ToString() == Session["repwd_Verification_code"].ToString())
{
string str = ConfigurationManager.ConnectionStrings["SQLCONN"].ConnectionString;
using (SqlConnection sqlcnn = new SqlConnection(str))
{
using (SqlCommand sqlcmm = sqlcnn.CreateCommand())
{
sqlcmm.CommandText = "select count(*) from users where name=@name and email=@email";
sqlcmm.Parameters.Add("@name", System.Data.SqlDbType.NVarChar, 10).Value = this.TextBox1.Text;
sqlcmm.Parameters.Add("@email", System.Data.SqlDbType.NVarChar, 100).Value = this.TextBox2.Text;
int num = 0;
sqlcnn.Open();
num = (int)sqlcmm.ExecuteScalar();
string sql = "update users set password=@pw where name=@name";
using (SqlConnection sqlCnn = new SqlConnection(str))
{
using (SqlCommand sqlCmm = sqlcnn.CreateCommand())
{
sqlCmm.Parameters.Add("@name", System.Data.SqlDbType.NVarChar, 10).Value = TextBox1.Text;
Myencrypt myen = new Myencrypt();
sqlCmm.Parameters.Add("@pw", System.Data.SqlDbType.NVarChar, 40).Value = myen.Encryptions("123456");
sqlCmm.CommandText = sql;
sqlCnn.Open();
sqlCmm.ExecuteNonQuery();
}
}
FSEmail();
if (num == 1)
{
Response.Write("<script>alert(恭喜您初始密码成功!您的初始密码为123456请妥善保管!)</script>");
Response.Redirect("login.aspx");
}
else
{
Response.Write("<script>alert(用户名或邮箱错误!)</script>");
}
}
}
}
else if (TextBox3.Text == "")
{
Response.Write("<script>alert('验证码不能为空!)</script>");
}
else if (TextBox3.Text != Session["repwd_Verification_code"].ToString())
{
Response.Write("<script>alert(“您输入的验证码有误!请重新输入!”)</script>");
}
}