Also I might point out that the code you presented here is highly vulnerable to a SQL injection attack.
I could go to the page that uses that code, and change the url so instead of ProdId=15, I could enter the url:
Code:
yourdomain.com/updatecart.asp?qty=0&custid=0&ProdId=';delete from User;//
Guess what would happen?
With ProdId equal to:
Code:
';delete from User;//
The code that gets executed is:
Code:
Delete From Cart Where ProdID=0 and CustID='';delete from User;//'
That's right, it deletes from Cart where CustId='',
then it deletes EVERYTHING FROM THE USER TABLE
then a comment afterwards to prevent any errors.
Of course, you might not have a User table, but it would be a simple matter to instead of deleting the user table, executing some other code to determine what tables you have, THEN deleting those tables, or altering data, or doing whatever I felt like to royally screw over your database.
Whenever you have user input that goes into a sql statement,
you MUST replace apostrophes with double apostrophes,
or strip them out completely,
otherwise hackers WILL eventually find your site and have happy time with your database.
This is called a SQL injection attack and is one of the most widely used attacks on the internet.
|