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

I still can't get this to work. Passing variables and Include file 3

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
US
I have an asp file called VerifyClient.asp like this:

<%@ Language=VBScript%>
<%Option Explict%>
<%
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=;pwd=;Server=Server;Database=Test&quot;
UserName = Request.Form(&quot;txtUserName&quot;)
PWord = Request.Form(&quot;txtPWord&quot;)
sql = &quot;Select * from ClientDB Where UserID = '&quot; & UserName & &quot;'&quot; & &quot;And Password = '&quot; & PWord & &quot;'&quot;
rs.Open sql, cnString, adOpenStatic, adLockOptimistic
If rs.BOF = True and rs.EOF = True Then
Window.Alert(&quot;NO&quot;)
Else
Window.Alert(&quot;YES&quot;)
end If
End If
%>

And I have an asp page like this:

<%@ Language=VBScript%>
<%Option explicit%>

<%
<!--#include File = &quot;../_scriptLibrary/VerifyClient.asp&quot;-->
%>
<!--DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;-->

<html>
<BODY>
<FORM Name=frmVerifyClient Method=post action=&quot;VerifyClient.asp&quot;>
<p><INPUT id=txtUserName name=text1></P>
<P><INPUT id=txtPWord name=text2></P>
<P><INPUT id=&quot;btnSubmit&quot; type=&quot;submit&quot; value=&quot;Continue&quot; name=&quot;submit&quot;></P>
</FORM>
</BODY>
</HTML>

Can't get it to work. I've tried it until I'm blue in the face. What am I doing wrong?? Rob
Just my $.02.
 
what error are you getting? provide tools to let people become their best.
 
I think the problem is that you are referring to the id value instead of the name value in th varification script. The easiest solution would be to make the name and id identical in both form inputs:
<p><INPUT id=txtUserName name=txtUserName></P>
<P><INPUT id=txtPWord name=txtPWord></P>
 
Include files become part of the page calling them (as if they were one page). You have two separate ASPs, which would cause problems. The first thing you would need to do is get rid of the <%@ Language=VBScript%> <%Option Explict%> from your inc file, because they're already in the calling page.

However, you cannot display error messages (window.alert) from server side code. What I'd recommend doing is something like this:

Main page:

<%@ Language=VBScript%>
<%Option explicit%>

<html>
<BODY>
<FORM Name=frmVerifyClient Method=post action=&quot;VerifyClient.asp&quot;>
<p><INPUT id=txtUserName name=text1></P>
<P><INPUT id=txtPWord name=text2></P>
<P><INPUT id=&quot;btnSubmit&quot; type=&quot;submit&quot; value=&quot;Continue&quot; name=&quot;submit&quot;></P>
</FORM>
</BODY>
</HTML>

VerifyClient.asp:

<%@ Language=VBScript%>
<%Option Explict%>
<%
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=;pwd=;Server=Server;Database=Test&quot;
UserName = Request.Form(&quot;txtUserName&quot;)
PWord = Request.Form(&quot;txtPWord&quot;)
sql = &quot;Select * from ClientDB Where UserID = '&quot; & UserName & &quot;'&quot; & &quot;And Password = '&quot; & PWord & &quot;'&quot;
rs.Open sql, cnString, adOpenStatic, adLockOptimistic
If rs.BOF = True and rs.EOF = True Then
Response.write &quot;No&quot;
'here you could also redirect to a &quot;No&quot; page, or do something
'more than justy writing &quot;No&quot;
Else
Response.write &quot;Yes&quot;
'As above, you could output any html here, or just redirect to another page.
end If
End If
%>

I haven't tested the above so don't know if everything will work, but I hope you get the idea.
 
I'm not really getting an error, just changes pages no matter what UserName is entered. Davmoor brings up a good point, I was using the ID Name. Sweevo, thanks a million for the code example. I'm going back to work on it now. I'll post the outcome. Rob
Just my $.02.
 
I finally got it. Thanks to all of you again for helping an asp newbie out and for your outstanding patience. Rob
Just my $.02.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top