hi i am new to c# and wondering if you could help me solve the problem to my login function for my website thanks
Code:
protected void btnlogin_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=CWsystem.mdb");
// OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["CWsystem.mdb"].ConnectionString);
con.Open();
string cmdStr="select count(*) from Person where UserID='" + txtusername.Text + "'";
OleDbCommand Checkuser=new OleDbCommand(cmdStr, con);
int temp = Convert.ToInt32(Checkuser.ExecuteScalar().ToString());
if(temp== 1)
{
string cmdStr2="Select Password from Person where username='" + txtusername.Text + "'";
OleDbCommand pass=new OleDbCommand(cmdStr2, con);
string password=pass.ExecuteScalar().ToString();
con.Close();
if(password == txtpassword.Text)
{
Session["New"] = txtusername.Text;
Response.Redirect("university.aspx");
}
else
{
Label1.Visible = true;
Label1.Text = "invalid password";
}
}
else
{
Label1.Visible = true;
Label1.Text = "invalid password";
}
}
protected void txtpassword_TextChanged(object sender, EventArgs e)
{
}
}
}