I have a problem with the login page. If I do not enter a username or password then it should say "Please enter a username or password" instead of going to the destination area, I mean, without entering anything in the login area, if I press the submit button I'm really welcome the page which should not be.
Here is my code. Please tell me where my fault is:
public class login {public string str = configuration manager. Connection strings ["connection string"]. ConnectionString.ToString (); Public at GetLogin (String Username, String Password) {SqlConnection con = New SqlConnection (str); SqlDataAdapter da = new SqlDataAdapter ("Choose from login * where username is named = '" + username + "' and password = '" + password + "' ', cone); dataset ds = new dataset (); da.Fill DS); if (DSTibles [0] .Raw.Count> 0) {If ((DSTB [0] .ROV [0] .EomArere [0] .Ostrong () == Username) & DS Tables [0] .Row [0] .imarere [1]. Ostring () == password)) {return1;} and {return 0;}} and {return -1;}} login.aspx.cs: protected void BtnLogin_Click (Object Sender, EventArgs e) {Session {"Users Name "] = TxtUserName.Text; login LG = new login (); if ((LG Geltogin (text text, TSTP password text) == 1)) {reaction. Redirect (" C. 1.spx "); } And if ((TxtUserName.Text == "") & amp; amp; (TxtPassword.Text == "")) {Lbl1.Text = "Please enter username and password";} Else {Lbl1.Text = "Sorry, invalid user name or password";}}
All this functionality first Created from asp.net only.
To validate your fields, use or to handle all the form functionality for yourself.
Check for user authentication and beyond.
Comments
Post a Comment