ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 9th, 2003, 03:56 AM
andyyylz andyyylz is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 14 andyyylz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How to validate user input

I am developing a web site which allow users to input sql query language for corresponding results.
But, are there any function or method in asp can check user input,instead of giving me errors back.
eg. There is a input field, allow user to input sql language, but if user input any wrong code,such as "dfds" "gergr". Those will incur error. How can I sort it out?


Cheers

Reply With Quote
  #2  
Old July 9th, 2003, 04:08 AM
Vantera Vantera is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: South Coast of NSW, Australia
Posts: 108 Vantera User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to Vantera
It is possible to tell ASP to ignore any errors that occur by adding the following line before your potentially erroneous code:
Code:
On Error Resume Next
__________________
Kind Regards,
John Rebbeck
john@interspire.com
ICQ# 74637937

Reply With Quote
  #3  
Old July 9th, 2003, 08:16 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to dhouston
You should probably write some validation code that looks for certain trends in the input. I have no idea how you'd do this in ASP, so I'll write it out in plain English.

First off, I don't imagine you're going to want anybody to do any DELETING or DROPPING or CREATING. I'd also be leery of allowing UPDATING from an interface like this, as your database stands a very good chance of being hosed. Your database privileges can prevent these types of actions, but it'd also be good to preempt that denial by sending back errors if users event attempt to perform these actions.

So you'd read in the query they submit and search the string for these key words. If you find one, print the appropriate error message and exit.

As for selects, you just need to validate the right query format. So you'd want to check to make sure a string started with "SELECT" (case-insensitive), then some text or numeric values and then "FROM" and at least one word following "FROM." Optionally, you should look for "WHERE" or "LEFT JOIN" or other sets of key words that'd fit here, followed by key/value pairs and either zero quotation marks or an even number of question marks.

If the query sent doesn't match the basic format of a valid query, error and return a message. The database does this, of course, but by first validating the queries, you're saving database load and ensuring that valid but malicious queries (DELETE * FROM users) don't get that far along in the process.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > How to validate user input


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek