简单登录问题????

taylermail taylermail 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;


public partial class admlg2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}

protected void Submit_ServerClick(object sender, EventArgs e)
{
if (this.user1.Value.Trim() != "")
{
if (this.Password1.Value.Trim() != "")
{
string temp1 = null;
string temp2 = null;
temp1 = this.user1.Value.Trim();
temp2 = this.Password1.Value.Trim();
string connectionstring = "Data Source=192.168.0.4;Initial Catalog=newcxgw;Persist Security Info=True;User ID=zhangjian;Password=cxgw";
SqlConnection con = new SqlConnection(connectionstring);
con.Open();
string cmdtext ="select * from admin where username='temp1' and password='temp2'";
SqlCommand cmd = new SqlCommand(cmdtext, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Session["用户id"] = dr["id"].ToString();
Response.Redirect("3.asp");
}
dr.Close();
con.Close();

}
else { this.Response.Write("<script>alert('用户名或密码错误1!')</script>"); }

}
else { this.Response.Write("<script>alert('用户名或密码错误2!')</script>"); };
}

}
...全文
评论 3
收藏 已收藏
分享
返回顶部
taylermail
C# 111,128 成员 642,536 内容