计算机专业毕业设计:[30]网站登录2
的有关信息介绍如下:![计算机专业毕业设计:[30]网站登录2](/upload/jingyan/2025/0905/28e2e1d0.jpg)
计算机专业的很多同学临近毕业了,才着急怎么做一个毕业设计来进行答辩。很短的时间是不可能完成的,天使预计用三个月的时间和计算机专业的同学分享一下怎么完成毕业之前的一项重要任务“毕业设计”。请小伙伴们跟上天使的步伐,在天使的带领下,一起完成你们的毕业设计吧。后期,天使还会讲解如何写毕业论文等,希望小伙伴们持续关注哦。
会员输入账号密码之后,登录成功跳转到如图所示界面
双击打开类文件【MyClass】写一个查询数据库是否存在相同记录文件的类
#region 判断是否已有相同的记录 public bool IsSameRecord(string scmd) { try { SqlConnection cn = this.Getcon(); cn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = scmd; SqlDataAdapter dataAdapter = new SqlDataAdapter(); dataAdapter.SelectCommand = cmd; DataSet dset = new DataSet(); dataAdapter.Fill(dset, "Info"); cn.Close(); cn.Dispose(); if (dset.Tables["Info"].Rows.Count > 0) return true; else return false; } catch { return false; } } #endregion
我们的网站会经常对数据库进行增删改查,我们可以直接写一个类,每次有类似操作的时候就调用这个类
每次登录成功之后,就保存用户名在电脑上,就不需要再次登录,所以我们写一个Cookies
public void WriteCook() { Response.Cookies["username"].Value = txtname.Text; Response.Cookies["username"].Expires = DateTime.Now.AddDays(1); }
双击登录按钮,在代码界面输入代码,首先查找是否存在这个用户,假如存在,那么在电脑上记录用户名,网页跳转到index0页面
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { try { string sqlcon = "select * from [user] where user_name='" + txtname.Text + "' and user_password='" + txtpwd.Text + "'"; if (myclass.IsSameRecord(sqlcon)) { WriteCook(); string sq = "update [user] set register_time='"+DateTime.Now.ToString()+"' where user_name='" + txtname.Text + "' "; myclass.ExCom(sq); Session["username"] = txtname.Text; Server.Transfer("~/index0.aspx"); } else { Response.Write(""); } } catch (Exception ex) { Response.Write(""); } }



