using System; using System.Collections; using System.Configuration; using System.Data; using System.Data.SqlClient; // sqli andmebaasiga seotud asjad using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } //protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) //{ // e.Authenticated = (Login1.UserName.ToLower() == "mati") && // (Login1.Password == "pwd"); //} protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { SqlConnection conn = new SqlConnection( ConfigurationManager. ConnectionStrings["veebipoebaasConnectionString"]. ConnectionString); SqlCommand cmd = new SqlCommand( "SELECT TOP 1 kasutajanimi FROM kasutajad " + "WHERE kasutajanimi = @nimi AND parool = @pwd"); cmd.Parameters.AddWithValue("nimi", Login1.UserName); cmd.Parameters.AddWithValue("pwd", Login1.Password); cmd.Connection = conn; conn.Open(); object tulemus = cmd.ExecuteScalar(); conn.Close(); e.Authenticated = tulemus != null; } }