Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
HTML
<!--#include file=../db.asp-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link href="styles.css" rel="stylesheet" type="text/css">
<title>Validate Login </title>
</head>
<body>

<p>&nbsp;</p>
<p>&nbsp;</p>
<table border="0" align="center">
  <tr>
    <td align="center" valign="top"><%
dim rs
if Request.Form("LoginID")<>"" and Request.Form("Password")<>"" then
	Set rs=Server.CreateObject("ADODB.RecordSet")
	rs.open "Select role from users where [UserID]='" & Request.form("LoginID") & "' and [Password]='" & Request.Form("Password") & "'",con,1,3
	if not rs.eof  then 
		Session("LoginID")= Request.form("LoginID")
		response.redirect("Managenews.asp")
	else
		response.write ("<h1 class=articleheader> Invalid login or password...</h1>")
		response.write ("<h3> <a href=index.htm class=txtlinks> Please Try Again...</a></h3>")
	end if
End if	
%></td>
  </tr>
</table>

</body>
</html>
Posted

Google for "VBScript parameterized sql queries".

Also, you're making the MASSIVE mistake of storing password in clear text in your database.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 2-Jan-16 17:07pm    
Good point about storing passwords, a 5; and I answered in detail about SQL injection.
—SA
"Path of fix SQL inject" sounds absurd. "SQL injection" is a malicious technique; it should not be "patched or fixed".

Your approach is wrong from the very beginning. The query composed by concatenation with strings taken from UI. Not only repeated string concatenation is inefficient (because strings are immutable; do I have to explain why it makes repeated concatenation bad?), but, of course, a way more important issue is the vulnerability to SQL injection.

This is how it works: http://xkcd.com/327.

Are you getting the idea? The string taken from a control can be anything, including… a fragment of SQL code.

What to do? Just read about this problem and the main remedy: parametrized statements: http://en.wikipedia.org/wiki/SQL_injection.

With ADO.NET, use this: http://msdn.microsoft.com/en-us/library/ff648339.aspx.

Please see my past answers for some more detail:
EROR IN UPATE in com.ExecuteNonQuery();,
hi name is not displaying in name?.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900