How to Secure Login Form using sql server DB
  • Hello i created a login form using SQL SERVER Backend but my login form password textbox also accept this type of input

    1) 1′ OR ’1′=’1--
    2) abc' or 1=1-- 

    is this anyway to protect my login form avoiding this type of inputs?
  • 3 Comments sorted by
  • Write a custom function to validate password input before send data to sql server table.You can use String.IndexOfAny(char[] anyOf) method to accomplish this.For example

    public bool ValidatePassword(char[] mychars)
       return true;
      return false;

  • Some examples:
            // A.
    // Input.
    const string value1 = "Darth is my enemy.";
    const string value2 = "Visual Basic is hard.";

    // B.
    // Find first location of 'e' or 'B'.
    int index1 = value1.IndexOfAny(new char[] { 'e', 'B' });

    // C.
    // Find first location of 'e' or 'B'.
    int index2 = value2.IndexOfAny(new char[] { 'e', 'B' });
  • Hi Hussain
    Jaguar777 example is best if want to accept some character you can also try keypress event and can restrict user there.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week