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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using input field for Query to db

Status
Not open for further replies.

streborr

IS-IT--Management
Jan 16, 2002
98
I'm trying to set up a login page to verify username and password thru a table in a database, if the the username and password are valid I want to send the user to a page that will show information from a database based on what group they're in.
Fields in Table:
user_login_ID, user_name, user_pass, user_group, etc...

Here's my code:
The input fields are from the login page.
and sent to this page.
<body>
<INPUT TYPE=&quot;text&quot; NAME=&quot;ID&quot; value=&quot;<% =Request.Form(&quot;login&quot;) %>&quot; size=&quot;20&quot;></INPUT>
<INPUT TYPE=&quot;text&quot; NAME=&quot;pword&quot; value=&quot;<% =Request.Form(&quot;password&quot;) %>&quot; size=&quot;20&quot;></INPUT>

<%
Set fp_conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set fp_rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
fp_conn.Open Application(&quot;leadinput1_ConnectionString&quot;)
fp_rs.Open &quot;Select * From tblUser Where user_login_ID = '&quot; & Request.Form(&quot;login&quot;) & &quot;' AND user_pass = '&quot; & Request.Form(&quot;password&quot;) & &quot;'&quot;, fp_conn, 1, 3, 1
%>
<-- this is here just to see if data can be pulled from the DB. -->
<%=FP_FieldVal(fp_rs,&quot;user_group&quot;)%>

<%Set fp_conn = nothing%>
<%Set fp_rs = nothing%>
</body>
</html>

Here's the error I received:

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'FP_FieldVal'

/members/leadinput1_interface/Results/editor/users/user_login.asp, line 21

Why wont it return the group that this user belongs to?
 
ok, i dont know the problem with the above, but here is the same script to do the same thing, in pure html... P.S this script assumes that you are using access, and that the input fields, are password, and name

**********************************************************

<%
Dim username, password
username=request.form(&quot;user&quot;)
password=request.form(&quot;pass&quot;)
if username=&quot;&quot; or password=&quot;&quot; then
%>
< form method=&quot;post&quot; action=&quot;(name of this page)&quot;>
<BR>Login ID :<input type=&quot;text&quot; name=&quot;user&quot; >
<BR>Password :<input type=&quot;password&quot; name=&quot;pass&quot; >
<BR><input type=&quot;submit&quot; value=&quot;submit&quot; Name=&quot;Continue&quot;>
</Form>
<%
Else
dim con, query
Set con = server.Createobject( &quot;ADODB.Connection&quot; )
Con.Open( &quot;DRIVER={Microsoft Access driver (*.mdb)}; DBQ=&quot; & server.MapPath(&quot;(place the path of the database here)ie fpdb/laws.mdb&quot; ) )
query=con.execute(&quot;SELECT * FROM table WHERE user_login_ID=&quot; & username )
if password = query(&quot;user_pass&quot;) Then
response.redirect (&quot;&quot; & user_group)
Else
response.redirect (&quot; (page that is the error page) &quot;)
end if
end if
con.close
set con = nothing
%>

********************************************

please note that you will need to add some info the this line

response.redirect (&quot;&quot; & user_group)

if the webpage you want to redirect to is set up as the goup, ie group/1/ or group/2/ 1 or 2 being the group, then you will need to do the following

response.redirect (&quot;group/&quot; & user_group)

Hope that helps,. if you have a problem contact me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top