dbWriter Home
IP to Country Look up
Site Map

IP to Country DB

Free Databases:

ASP Code

ASP Links

VB Script functions:
Array
Case/Select
In String (inStr)
Replace

HTML code:
SELECT Color
SELECT Countries
SELECT Language
SELECT State/Province

SQL:

SQL Functions:
Delete leading Char
Get Browser
Long number from IP

Stored Procedures:

SQL Tricks:
Delete ALL duplicates
Delete dup records

MISC
IP Address Owner
MS SQL Server

Mortgage Calcs:
how much is my payment
Loan Amortization
Loan Calculator
Mortgage Calculator
Motrgage Pay Off

dbWriter License

Link to US

Links

Contact US
 

dbWriter Preventing SQL Injection Attacks ASP code

Trusting user input can prove fatal to SQL via SQL injection... code inserted in input html input boxes.  All user inputs must be checked before adding or deleting data from your database.  SQL injection attacks often use potentially hazardous characters to "inject" into a sql statement. They take advantage of code that does not filter input that is being entered directly into a form or a query string.

NEVER trust anything your users input.

DIM strUsername, strPassword

strUsername=Request.Form("txtUsername")
strPassword=Request.Form("txtPassword")
 

single quote clean up is first
strUsername=replace(strUsername,"'","''")
strPassword=replace(strPassword,"'","''")

Then, call the function SQLcheck to check for illegal characters

If SQLcheck(strUsername)=True OR SQLcheck(strPassword)=True Then
Response.redirect("error.asp")
End If

<%
Function SQLcheck(strInput)
DIM sBadChars, iCounter
SQLcheck=False

'Array of illegal characters and words
arrBadChars=array("select", "drop", ";", "--", "insert", "delete", "xp_", _
                               "#", "%", "&","(", ")", "/", "\", ":", ";", "<", ">", "=", "[", "]", "?", "`", "|")
'Loop through array arrBadChars
For iCounter = 0 to uBound(arrBadChars)

If Instr(strInput,arrBadChars(iCounter))>0 Then
SQLcheck=True
End If
Next
End function
%>
updated 4/18/07
Partners/Links © 2005 - 2008 dbWriter.com All Rights Reserved
This site is protected by the dbWriter IPtoCountry MS/SQL database!!
Site map | Link to US
Contact Us

Sign up for PayPal and start accepting credit card payments instantly.