Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using SQL fields as L/P to control access to a form 1

Status
Not open for further replies.

demchak

IS-IT--Management
Jun 29, 2001
36
US
I have a SQL datasource set up that I use to feed our divisions training intranet site. My EmployeeInfo table contains the fields employee# and password. On the site there is a form that is used to check what classes you have taken. I would like to use the input from the form to run the query only if the UserID/Password match. I understand the basics of the if/then/else and the Request.form in ASP but getting the data from the SQL server and comparing it to the form data is proving to be harder than I thought. I have access to both a datasource (set up on the webserver to the SQL server) and a L/P to the SQL server on the LAN. I am a fair programmer but have never used ASP before. Any ideas would be greatly appreciated!!

Wes
 


demchak,


This is some code I use for my database.

Cheers,
Fengshui1998

<%
username = request.form(&quot;username&quot;)
password = request.form(&quot;password&quot;)

' make your database connection
Set CnTmp = CreateObject(&quot;ADODB.Connection&quot;)
CnTmp.open strConn = &quot;PROVIDER=SQLOLEDB;&quot; & _
&quot;DRIVER={SQL Server};&quot; & _
&quot;SERVER=&quot; & SQL_Svr & &quot;;&quot; & _
&quot;DATABASE=&quot; & DataBase & &quot;;&quot; & _
&quot;UID=&quot; & UID & &quot;;&quot; & _
&quot;PWD=&quot; & PASSWORD

strSQL = &quot;SELECT * FROM usertable WHERE USER='&quot; & _
username & &quot;'&quot;

Set rsTmp = CreateObject(&quot;ADODB.Recordset&quot;)
rsTmp.open strSQL, CnTmp, 1, 3
if rstmp.recordcount > 0 then
dbpwd = rstmp(Password&quot;)
if (dbpwd = password) then
response.write &quot;User verified&quot;
else
response.write &quot;Passwords don't match.&quot;
end if
else
response.write &quot;User does not exist.&quot;
end if

%>
 


demchak,

dbpwd = rstmp(Password&quot;)

should be:

dbpwd = rstmp(&quot;Password&quot;)

Sorry,

Fengshui1998
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top