设为首页 加入收藏 网站搜索 繁體中文 中国建站网 — 站长资源分享平台

一个最简单的会员登陆代码

来源:网络收集 作者:佚名 时间:2007-04-25 23:45:29
是用来新手入门的,高手们不要见笑呀!
string conn = "server=.;database=login;user id=sa;pwd=123";
        SqlConnection cn = new SqlConnection(conn);
        cn.Open();
        string strsql = "select user_name,user_pwd from admin where user_name='" + TextBox1.Text + "' or user_pwd='" + TextBox2.Text + "'";
        SqlCommand cmd = new SqlCommand(strsql, cn);
        SqlDataReader rd = cmd.ExecuteReader();
        if (rd.Read())
        {
            if (rd.GetValue(0).ToString() == TextBox1.Text)
            {
                if (rd.GetValue(1).ToString() == TextBox2.Text)
                {
                    Response.Redirect("Default.aspx");
                }
                else
                {
                    Response.Write("<script>alert('密码错误!')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('用户名错误!')</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('用户不存在!')</script>");
        }
    }

Tags:

  • 好的评价 如果您觉得好,就请您
      0%(0)
  • 差的评价 如果您觉得差,就请您
      0%(0)
  • 相关文章
    广告赞助

    文章随便看看 设计素材 建站学院 网页模板 视频教程

    网友评论

    共有 0 位网友发表了评论,得分 0 分,平均 0 分    查看完整评论

    用户名: 查看更多评论

    分 值:100分 85分 70分 55分 40分 25分 10分 1分

    内 容:

             通知管理员 验证码: