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

Use Include file? 2

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
US
I have an .asp file I want to check a username and password with, matching it to an SQL Database. The .asp file reads like this:

<%Language=VBScript%>
<%Option Explicit%>
<%
Dim cn, rs, cnString, UserName, PWord

Set rs = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
cnString = &quot;Driver=SQL Server;uid=sa;pwd=;Server=RobHome;Database=Test&quot;

%>

<%
Sub VerifyClient()
Request.QueryString(&quot;UserName&quot;)
Request.QueryString(&quot;PWord&quot;)
sql = &quot;Select * from ClientDB Where UserID = '&quot; & UserName & &quot;'&quot; & &quot;And Password = '&quot; & PWord & &quot;'&quot;
rs.Open sql, cnString
If rs.BOF = True and rs.EOF = True Then
Window.Alert(&quot;NO&quot;)
Else
Window.Alert(&quot;Yes&quot;)
End If
End Sub
%>

How do I go about calling this from the page where the UserName and PassWord are entered? Rob
Just my $.02.
 
Submit your username and password to the same form and check with the value of submit button.

This is the sample code for u
save this file as &quot;samefile.asp&quot;


<%Language=VBScript%>
<%Option Explicit%>
<%
if ucase(request.form(&quot;submit&quot;))=&quot;SUBMIT&quot; then
Dim cn, rs, cnString, UserName, PWord
Set rs = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
cnString = &quot;Driver=SQL Server;uid=sa;pwd=;Server=RobHome;Database=Test&quot;
Request.Form(&quot;UserName&quot;)
Request.Form(&quot;PWord&quot;)
sql = &quot;Select * from ClientDB Where UserID = '&quot; & UserName & &quot;'&quot; & &quot;And Password = '&quot; & PWord & &quot;'&quot;
rs.Open sql, cnString
If rs.BOF = True and rs.EOF = True Then
Window.Alert(&quot;NO&quot;)
Else
Window.Alert(&quot;Yes&quot;)
End If
end if
%>
<html>
<body>
<form name=f1 method=post action=&quot;samefile.asp&quot;>
Enter your name <input type=&quot;text&quot; name=&quot;textfield2&quot;>
Password <input type=&quot;password&quot; name=&quot;textfield&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;submit&quot;>
</form>
</body>
</html>

try this
have a nice programming
webspy

 
Thanks Webspy. I appreciate your help. Rob
Just my $.02.
 
Is there someway to call this from clientside without using a Submit button. I don't really want the button to read &quot;Submit&quot; I would like it to read &quot;Continue&quot; or &quot;Log In&quot; I'm so confused. I know what I want to do like I did in VB, but I can't seem to get the hang of it in ASP. The passing variables is &quot;killing&quot; me. Rob
Just my $.02.
 
Just change the value of the button to read what you want
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;submit&quot;>
to
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Continue&quot;>
if that would be sufficient for your needs.

Will UserName and PWord work in the SQL statement without creating variables for them? Asking not questioning!

this how I would think you would write it but may be wrong
UserName=Request.Form(&quot;UserName&quot;)
PWord=Request.Form(&quot;PWord&quot;)
sql = &quot;Select * from ClientDB Where UserID = '&quot; & UserName & &quot;'&quot; & &quot;And Password = '&quot; & PWord & &quot;'&quot;


provide tools to let people become their best.
 
Onpnt,

Thanks for the reply. I'm just starting out in asp. I made an app in VB and now &quot;the man&quot; wants it to be a web app. So far it has been very confusing to me on how to pass a variable from one page to the other. In VB I could just put the code in between the Load and Show. Like:

Load Form2
form2.textbox = form1.textbox
Form2.Show

It just has me frustrated. I'm not even sure that's the way it should be done. I'm very open to suggestions. I appreciate your saying &quot;asking not questioning&quot; but at this point you would be right to question.

I know the code I posted should check the database, I'm just confused on how to pass it to the next form or asp file.

If there is a better way, PLEASE feel free to tell me.

Thanks again. Rob
Just my $.02.
 
rtshort == sit back and relax, and remember how much you love doing this.

after the user enters the data into a form, passing values from one page to another in the session is fairly simple. The only things you really have to rememeber is when using the &quot;GET&quot; method use
Request.QueryString(&quot;UserName&quot;)
and the &quot;POST&quot;
Request.Form(&quot;UserName&quot;)
everything looks good from where I'm sitting how you are checking the DB.
after that criteria is met do what you will with the data from the form declaring var's and using the Request methods.
happy coding!!
provide tools to let people become their best.
 
Thanks again onpnt, I guess I do need to relax a little. Rob
Just my $.02.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top