codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  syntax for case insensitive  Archive Import (diego) at 22:43 on Thursday, August 07, 2003
 

i want to ask, i am using sql server 7 and i want my login to be case insensitive?
pls. help me with the script for this.

thanks

  Re: syntax for case insensitive  Troy Wolf at 10:03 on Friday, August 08, 2003
 

I`m going to assume that you have a webpage with a form that submits to an ASP page, and in that ASP page, you want to build a SQL query. Unfortunately, additional line breaks may be inserted when pasting the code in the forum.

`First get the variables from the Form.
strUname = Request.Form("Username")
strPword = Request.Form("Password")

`Now build the SQL query.
sql = "select * from account" & _
" where UPPER(uname) = `" & UCase(Replace(strUname,"`","``")) & "`" & _
" and UPPER(pword) = `" & UCase(Replace(strPword,"`","``")) & "`"

Notice the Replace() command! This is very important! You must replace single ticks with 2 single ticks. If you do not do this, it is VERY easy for anyone to enter a username and password that will "authenticate". For example, if a user enters:

Username: hacker
Pssword: ` or `A` = `A

If you do not do the replace, you would end up with a query like this:

select * from account
where UPPER(uname) = `hacker`
and UPPER(pword) = `` or `A` = `A`

This query would return all account records!
Troy Wolf: site expert
SnippetEdit Website Editor









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  onChange issue
•  Remote program execution using cgi-perl
•  Chat application
•  How to send multiple perameters in SOAP request.
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007