Forget_password.aspx.cs

(完整代码) 2KB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class Forget_password : System.Web.UI.Page
{
    string str = System.Configuration.ConfigurationManager.AppSettings["str_con"].ToString(); //连接数据库 
    SqlConnection con = null;
    SqlCommand cmd = null;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void but_subit_Click(object sender, EventArgs e)
    {
        con = new SqlConnection(str);
        con.Open();
        string sql = "SELECT * FROM [dbo].[顾客信息] where username = '" + text_yhm.Text.Trim() + "'";
        cmd = new SqlCommand(sql, con);
        SqlDataReader dr = cmd.ExecuteReader();
        if (dr.Read())
        {
            string yhm = dr["username"].ToString(); //dr["password"].ToString();
            if (yhm == text_yhm.Text.Trim())
            {
                if (text_newpwd.Text.Trim() != text_okpwd.Text.Trim())
                {
                    Response.Write("<script>alert('两次输入密码不同!')</script>");
                    text_newpwd.Text = "";
                    text_okpwd.Text = "";
                    text_newpwd.Focus();
                    return;
                }
                else
                {
                    dr.Close();
                    string str_uppwd = "UPDATE [dbo].[顾客信息] SET password ='" + text_okpwd.Text.Trim() + "' WHERE username = '" + text_yhm.Text.Trim() + "'";
                    SqlCommand cmd1 = new SqlCommand(str_uppwd, con);
                    cmd1.ExecuteNonQuery();
                    con.Close();
                    Response.Write("<script>alert('修改成功');window.location='startPage.aspx';</script");
                }
            }

        }
        else
        {
            Response.Write("<script>alert('用户名,请重新输入!')</script");
            return;
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。