我在做一个html的界面 界面上有两个textbox用来登陆 ,在用户输入信息并且点击提交后 ,将数据与数据库中的数据比较 当正确就用“xxx您好”
错误就“”;
我想应该是用js获取数据库中的数据,然后与文本框中的数据匹配,不知道是不是
希望大家指点指点
尽量明白点
错误就“”;
我想应该是用js获取数据库中的数据,然后与文本框中的数据匹配,不知道是不是
希望大家指点指点
尽量明白点
解决方案 »
- Stream.Read方法
- 能把Win32_NetworkAdapterConfiguration类中IPEnabled为True的实例锁定不?
- C# 由csv文件向sql中导入数据算法问题
- ListView 放了背景图片,没有数据的时候能看到背景,有数据怎么就看不到背景了呢?
- Management指定默认打印机时出错,请教各位高人?
- 在winform中如何订阅textBox控件中LostFocus事件呢
- C#24位位图转化成8位彩色图像
- C#水晶报表问题 急?
- 为何带有Owner的窗体无法失去焦点?
- 用oop的设计应该怎么做?
- 各位大虾们请进,求房地产销售软件源代码
- 试用版的软件,它用的是什么数据库?
ajax我不会啊
如果是客户端的控件,建议你用Ajax代码实现
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 class ttestt_Default : System.Web.UI.Page
{
static string constring = System.Configuration.ConfigurationManager.ConnectionStrings["goodsmisdbConnectionString"].ToString(); protected void Page_Load(object sender, EventArgs e)
{
lbmsg.Text = "";
uid.Focus();
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Session["username"] != null)
{
Session["username"] = null;
}
if (Session["usertype"] != null)
{
Session["usertype"] = null;
}
RequiredFieldValidator1.ErrorMessage = "";
string username = uid.Text.Trim();
string password = pwd.Text.Trim();
lbmsg.Text = "";
SqlConnection myConn = new SqlConnection(constring);
myConn.Open();
SqlCommand isLockCom = new SqlCommand("isLocked", myConn);
isLockCom.CommandType = CommandType.StoredProcedure;
isLockCom.Parameters.AddWithValue("@username", username);
int pd = -1;
pd = Convert.ToInt32(isLockCom.ExecuteScalar());
if (pd != 1)
{
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConn;
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.CommandText = "uidPwd";
myCommand.Parameters.AddWithValue("@username", username);
myCommand.Parameters.AddWithValue("@password", password);
SqlDataReader myRead = myCommand.ExecuteReader(); if (myRead.Read() == true)
{
string flag = myRead.GetValue(1).ToString();
myRead.Close();
SqlCommand myCommand2 = new SqlCommand();
myCommand2.Connection = myConn;
myCommand2.CommandType = CommandType.StoredProcedure;
myCommand2.CommandText = "SetErrTimesZero";
myCommand2.Parameters.AddWithValue("@username", username);
myCommand2.ExecuteNonQuery();
myConn.Close(); Session.Timeout = 60;
Session["username"] = uid.Text.Trim();
Session["usertype"] = flag;
Response.Redirect("~/login/default.aspx");
}
else
{
Response.Write("<script>window.alert('用户名或密码错误,请重新输入!')</script>");
myRead.Close(); SqlCommand errCommand1 = new SqlCommand();
errCommand1.Connection = myConn;
errCommand1.CommandText = "haveUserAndErr";
errCommand1.CommandType = CommandType.StoredProcedure;
errCommand1.Parameters.AddWithValue("@username", username);
SqlDataReader myRead1 = errCommand1.ExecuteReader();
if (myRead1.Read())
{
int times = (int)myRead1.GetValue(1);
myRead1.Close();
SqlCommand addErrorCom = new SqlCommand("addErrorTimes", myConn);
addErrorCom.CommandType = CommandType.StoredProcedure;
addErrorCom.Parameters.AddWithValue("@username", username);
addErrorCom.ExecuteNonQuery();
switch (times)
{
case 1:
{
lbmsg.Text = "此用户已两次输入错误口令,若再次错误用户名将被锁!";
uid.Text = "";
pwd.Text = "";
uid.Focus();
break;
}
case 2:
{
SqlCommand lockUserCom = new SqlCommand("lockUser", myConn);
lockUserCom.CommandType = CommandType.StoredProcedure;
lockUserCom.Parameters.AddWithValue("@username", username);
lockUserCom.ExecuteNonQuery();
lbmsg.Text = "此用户名被锁,请与管理员联系!!";
uid.Text = "";
pwd.Text = "";
break;
}
} }
myRead1.Close();
myConn.Close();
uid.Focus();
}
}
else
{
lbmsg.Text = "此用户名被锁,请与管理员联系!";
uid.Text = "";
pwd.Text = "";
myConn.Close();
}
}
}
你见过html中有服务器控件?
上面代码太难了看不懂,,在下一小鸟