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!

Now What??

Status
Not open for further replies.

Trudye

Programmer
Sep 4, 2001
932
US
I want to password protect a certain area of my site. I think I have managed to create the the call (time will tell). What command(s) do I need to point to the next link. If the pswd is good where do I place the URL for the subsequent page.

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<% @LANGUAGE = VBSCRIPT %>
<%

DIM sQry, rs, Cnn1, myDSN, recfnd, strUserID
dim UserId
UserId = request.form(&quot;strUserID&quot;)


WhatNow = request.querystring=(&quot;action&quot;)


Set Cnn1 = Server.CreateObject(&quot;ADODB.Connection&quot;)
Cnn1.connectiontimeout=30
Cnn1.commandtimeout=40
myDSN=&quot;PROVIDER=Microsoft.Jet.OLEDB.4.0;&quot;
myDSN=myDSN & &quot;data source=C:\Access 7.0 Data\My_data.mdb;&quot;

Cnn1.Open(myDSN)

If request.form(&quot;UserID&quot;) = Null then
cnn1.close
set cnn1 = nothing
Response.write &quot;<a href='UserLogon.asp'>&quot;
Response.write &quot;You must enter your ID &quot;
response.write &quot;</a>&quot;
end if

recfnd = false

sQry = &quot;SELECT ID FROM VisitorLogonTbl&quot;
SQry = SQry & &quot;Where ID=&quot; & UserID

set rs = Cnn1.execute(sQry)

If (strComp(rs(&quot;ID&quot;), UserID) = 0) then
recfnd = true
end if
If recfnd = false then
rs.close
set rs = nothing
cnn1.close
set cnn1 = nothing
Response.write &quot;<a href='UserLogon.asp'>&quot;
Response.write &quot;Invalid User ID &quot;
response.write &quot;</a>&quot;
response.end
end if
%>

Thank you so much
Trudye
 
instead of this
Response.write &quot;<a href='UserLogon.asp'>&quot;
Response.write &quot;You must enter your ID &quot;
response.write &quot;</a>&quot;
do a redirect

response.redirect(&quot;UserLogon.asp&quot;)

and if the user id matches your query then redirect to the next page that is being accessed

You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
I think this may do it.
<% @LANGUAGE = VBSCRIPT %>
<%

DIM sQry, rs, Cnn1, myDSN, recfnd, strUserID
dim UserId
UserId = request.form(&quot;strUserID&quot;)
If UserId = Null then
Response.redirect &quot;UserLogon.asp&quot;
Response.write &quot;you must fill in a user id&quot;
end if

Set Cnn1 = Server.CreateObject(&quot;ADODB.Connection&quot;)
Cnn1.connectiontimeout=30
Cnn1.commandtimeout=40
myDSN=&quot;PROVIDER=Microsoft.Jet.OLEDB.4.0;&quot;
myDSN=myDSN & &quot;data source=C:\Access 7.0 Data\My_data.mdb;&quot;

Cnn1.Open(myDSN)

recfnd = false

sQry = &quot;SELECT ID FROM VisitorLogonTbl&quot;
SQry = SQry & &quot;Where ID=&quot; & UserID

set rs = Cnn1.execute(sQry)

If (strComp(rs(&quot;ID&quot;), UserID) = 0) then
recfnd = true
Response.redirect &quot;accessed.asp&quot;
else
rs.close
set rs = nothing
cnn1.close
set cnn1 = nothing
Response.redirect &quot;UserLogon.asp&quot;

end if
%> You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
You can't put writing after a response.redirect they wont see the text ;) www.vzio.com
ASP WEB DEVELOPMENT



 
Thank you all for your input. I obviously have a lot to learn about vbscript and web development. Although this is a test project I will try your recommendations asap.

Unfortunately I have to work for a living my dowry got wiped out on tech stocks(smile).

Thanks again
Trudye
 
Try this ...

Response.redirect &quot;UserLogon.asp?Error=UserID&quot;

then on the UserLogon.asp get the type of error it is

ErrorType = Request.Querystring(&quot;Error&quot;)

Select Case ErrorType
Case &quot;UserID&quot;
strMessage = &quot;You must enter a UserID&quot;
Case &quot;Password&quot;
strMessage = &quot;You must enter a password&quot;
case &quot;BadUserID&quot;
strMessage = &quot;UserID entered is invalid&quot;
case &quot;BadPassword&quot;
strMessage = &quot;Password entered is invalid&quot;
.
.
.
.
end select

then at the select a place on the page you wish to display your message..

Response.write strMessage

Dont worry if there is no message returned nothing will display.

This will redirect you with the error message within the query string. Here is one option.

Happy coding
Reza

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top