我现在完成了登录代码编写,并已将登录信息记录到了session中。我前台代码应该怎样写,才能区分 用户登录前后的不同区域的不同内容显示有朋友能提供一段代码参考下,或者 帮忙讲解一下 具体的实现原理及步骤。 谢谢了
解决方案 »
- 求开源商城!来者有分!
- webService引用问题。
- 软件开发中遇到一个问题,真诚的向大家请教!
- SQL 统计当日更新数量语句
- textbox的内容如何提交到服务器上的一个表
- 如何点击图片跳转到下一张?
- gridview绑定数据分页问题
- 一个正则表达式处理问题
- 提问:从.aspx页面提交到令一个.aspx页面去处理问题!请大伙来看看不够+分,顶者有分SOS
- 100分 明天天早就接分 求一正则表达式用来匹配日期
- 已成功与服务器建立连接,但是在登录过程中发生错误。 (provider: 共享内存提供程序, error: 0 - 管道的另一端上无任何进程。)
- 关于gridview列表以及多条件查询?
不明加我qq 975292958
{
SqlConnection conn = new SqlConnection(SqlHelp.ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("select * from tbUsers where iUserName = '" + TextBox_iUserName.Text.Trim() + @"' and sPassword = '" + TextBox_sPassword.Text.Trim() + @"' ", conn);
DataSet ds = new DataSet();
try
{
da.Fill(ds);
if (ds != null)
{
if (ds.Tables[0].Rows.Count == 1)
{
Session["iUserName"] = ds.Tables[0].Rows[0]["iUserName"].ToString();
Session["sPassword"] = ds.Tables[0].Rows[0]["sPassword"].ToString();
Session["iUserID"] = ds.Tables[0].Rows[0]["iUserID"].ToString();
Session["iLevels"] = ds.Tables[0].Rows[0]["iLevels"].ToString();
Response.Redirect("main.aspx");
}
else
{
Response.Write("帐号或密码错误!");
}
}
else
{
Response.Write("帐号或密码错误!");
}
}
catch
{ }
finally
{
conn.Close();
conn.Dispose();
conn = null;
}
{
conn.Open();
string sql = "select * from tb where name='" + name.Text + "'";
SqlCommand command = new SqlCommand(sql, conn);
SqlDataReader reader = command.ExecuteReader();
if (reader.Read())
{
if(dr["password"].ToString().Equals(txtpass.text.Trim()))
{
Session["name"] = name.Text;
Response.Redirect("index.aspx"); }
}
else
{
Session["name"] = "";
Label1.Text = "登录失败,无此用户名或者密码不正确!";
}
connc.Close();
}
或使用数据库操作类,查询数据或参数化
什么意思不太懂判断session是否存在 写相关代码就可以了if(session["user"]==null)
{
Panel1.Visible = false;
}
else
{
Panel2.Visible = true;}