Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-28-2003, 03:00 PM   #16 (permalink)
berklee
Registered User
 
Join Date: Mar 2003
Posts: 18
berklee is on a distinguished road
Or you could use PythonScript for ASP.

I'm just sayin'. :p
berklee is offline   Reply With Quote
Old 03-28-2003, 03:16 PM   #17 (permalink)
abc123
bloomberg
 
abc123's Avatar
 
Join Date: Jun 2002
Location: bloomberg
Posts: 263
abc123 is on a distinguished road
Send a message via AIM to abc123 Send a message via Yahoo to abc123
Re: Really?

Quote:
Originally posted by berklee
what about a simple select?

Select * from myTable where keyfield = 1

If that 1 is pulled from a page (say a drop-down list), you can build a page that makes a value:

<input type="hidden" name="keyfield" value="1;drop database test'">
.. well don't i look stupid.. you should always make sure integer values you expect only contain numbers then
__________________
-- bloomberg.
abc123 is offline   Reply With Quote
Old 03-28-2003, 06:58 PM   #18 (permalink)
rdove
Masked Moderator
 
rdove's Avatar
 
Join Date: May 2002
Location: Indianapolis, IN
Posts: 260
rdove is on a distinguished road
Re: Re: Really?

Quote:
Originally posted by abc123
.. well don't i look stupid.. you should always make sure integer values you expect only contain numbers then
I totally agree..I would say something like:

Code:
Select * from myTable where keyfield = " & CInt(request.form("box"))
__________________
~Ryan

rdove is offline   Reply With Quote
Old 03-28-2003, 07:03 PM   #19 (permalink)
rdove
Masked Moderator
 
rdove's Avatar
 
Join Date: May 2002
Location: Indianapolis, IN
Posts: 260
rdove is on a distinguished road
Quote:
Originally posted by berklee
That's certainly a good thing....

But what about when you run statements on a mySQL database that require the contents of text form fields?

For the record, I'm not trying to be a pain. If you can help me understand a relatively secure way to do this, it might change my opinions on mySQL.
Here is a little function I call in one of my create pages:

Code:
    dim Char_Array(31)
    
    Char_Array(0) = "~"
    Char_Array(1) = "`"
    Char_Array(2) = "!"
    Char_Array(3) = "@"
    Char_Array(4) = "#"
    Char_Array(5) = "$"
    Char_Array(6) = "%"
    Char_Array(7) = "^"
    Char_Array(8) = "&"
    Char_Array(9) = "*"
    Char_Array(10) = "("
    Char_Array(11) = ")"
    Char_Array(12) = "-"
    Char_Array(13) = "+"
    Char_Array(14) = "="
    Char_Array(15) = "/"
    Char_Array(16) = "\"
    Char_Array(17) = "|"
    Char_Array(18) = "]"
    Char_Array(19) = "["
    Char_Array(20) = "{"
    Char_Array(21) = "}"
    Char_Array(22) = "'"
    Char_Array(23) = ":"
    Char_Array(24) = ";"
    Char_Array(25) = "?"
    Char_Array(26) = ">"
    Char_Array(27) = "<"
    Char_Array(28) = "."
    Char_Array(29) = ","
    Char_Array(30) = """"
    
    'check the user name for invalid characters
    for i = 0 to 30
      Pos = instr(Request.Form("textbox"), Char_Array(i))
	  
      if Pos > 0 then
        Response.Redirect("page.asp?status=char")
      end if
    next
__________________
~Ryan

rdove is offline   Reply With Quote
Old 03-30-2003, 05:50 PM   #20 (permalink)
berklee
Registered User
 
Join Date: Mar 2003
Posts: 18
berklee is on a distinguished road
Not bad...

The only other thing I'd recommend would be copying the Form field value to a variable, so that it cuts processing power required to do the job (you won't be accessing a property of a component on each iteration of the loop).

PS - In a perfect world, this would be better handled in JavaScript. You could do one regexp pass and it would take way less overhead. Not that I've ever done it.
berklee is offline   Reply With Quote
Old 03-30-2003, 06:21 PM   #21 (permalink)
abc123
bloomberg
 
abc123's Avatar
 
Join Date: Jun 2002
Location: bloomberg
Posts: 263
abc123 is on a distinguished road
Send a message via AIM to abc123 Send a message via Yahoo to abc123
you can do regexp in asp.
__________________
-- bloomberg.
abc123 is offline   Reply With Quote
Old 03-30-2003, 08:37 PM   #22 (permalink)
berklee
Registered User
 
Join Date: Mar 2003
Posts: 18
berklee is on a distinguished road
Yeah, but you have to instantiate a COM component to make it happen (with VBScript)

With Javascript, it's part of the language and wouldn't take up the overhead of creating a new object.

Server-side JScript would be the way to go.
berklee is offline   Reply With Quote
Old 03-30-2003, 09:07 PM   #23 (permalink)
abc123
bloomberg
 
abc123's Avatar
 
Join Date: Jun 2002
Location: bloomberg
Posts: 263
abc123 is on a distinguished road
Send a message via AIM to abc123 Send a message via Yahoo to abc123
Quote:
Originally posted by berklee
Yeah, but you have to instantiate a COM component to make it happen (with VBScript)

With Javascript, it's part of the language and wouldn't take up the overhead of creating a new object.

Server-side JScript would be the way to go.
if you're concerned about speed, don't use asp
__________________
-- bloomberg.
abc123 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Would you mind if there were small flash elements at code newbie? sde Lounge 10 05-29-2004 10:05 PM
Cisco Code breaking sde Code Newbie News 0 05-21-2004 08:10 AM
Microsoft probes Windows code leak redhead Code Newbie News 0 02-13-2004 01:41 AM


All times are GMT -8. The time now is 12:33 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting