求助:如何制作一个页面实现用户登录? 见标题;界面如图用户名:□密码:□然后两个button键:登录,取消要求:用户名和密码从数据库中读取,如正确,提示登录成功,如错误,提示用户名或密码错误各位大神,姑娘的性命就托付给你们了T.T 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 界面用html input 标签要有name属性 后台用request获取 查数据库验证是否通过 通过则session储存一下 每个页面都判断一下session是否合法 以判断是否登录 如果是c#的话就是这样的你们应该有通用类吧..假定叫sqlhelper返回单行单列的方法叫obj()吧sqlhelper sql=new sqlhelper();object o=sql.boj(this.用户名控件.text,this.this.密码.text);if(Convert.Toint32(O)==0){//写失败的代码}else{//写成功的} 这个百度或Google下、或看看相关书,即可解决。 private void button1_Click(object sender, EventArgs e)//登录按钮单击事件{string name=textbox1.text;string pwd=textbox2.text;SqlConnection conn=new SqlConnection("server=服务器名(如果是本地数据库就填".");database=数据库名;uid=sa;password=密码(没有不填)");conn.Open();string sql = "select count(*) from 表名 where 用户名列=@name and 密码列=@pwd";SqlCommand cmd = new SqlCommand(sql, conn);cmd.Parameters.Add("@name", SqlDbType.VarChar, 50).Value = name;cmd.Parameters.Add("@pwd", SqlDbType.VarChar, 50).Value = pwd;int count = Convert.ToInt32(cmd.ExecuteScalar());if (count > 0){ MessageBox.Show("登录成功");}else{ MessageBox.Show("用户名或密码错误");}private void button2_Click(object sender, EventArgs e)//取消按钮单击事件{Application.Exit();//退出程序} C#问题,高手来啊 C#调用C++ dll指针的问题 Winform如何记住修改密码,使得下次登陆密码为这次的修改密码啊? 如何设置窗体类属性的默认值? 怎么样更新DataSet里的数据??? 请教大家关于remoting 的Singleton方式 关于2个XmlDocument 请问FolderNameEditor在那个命名空间 程序在个别电脑上无法启动,无任何提示 trackbar的使用问题 如何监控多台PC上的共享文件夹和FTP文件是否存在超过5分钟的文件 请问,HTML元素的属性和方法
你们应该有通用类吧..假定叫sqlhelper
返回单行单列的方法叫obj()吧
sqlhelper sql=new sqlhelper();object o=sql.boj(this.用户名控件.text,this.this.密码.text);if(Convert.Toint32(O)==0)
{
//写失败的代码
}
else
{//写成功的
}
{
string name=textbox1.text;
string pwd=textbox2.text;
SqlConnection conn=new SqlConnection("server=服务器名(如果是本地数据库就填".");database=数据库名;uid=sa;password=密码(没有不填)");
conn.Open();
string sql = "select count(*) from 表名 where 用户名列=@name and 密码列=@pwd";
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add("@name", SqlDbType.VarChar, 50).Value = name;
cmd.Parameters.Add("@pwd", SqlDbType.VarChar, 50).Value = pwd;
int count = Convert.ToInt32(cmd.ExecuteScalar());
if (count > 0)
{
MessageBox.Show("登录成功");
}
else
{
MessageBox.Show("用户名或密码错误");
}private void button2_Click(object sender, EventArgs e)//取消按钮单击事件
{
Application.Exit();//退出程序
}