username redirect

R

rml

How can I make a user enter his or her username and
password, then have them redirected to another page
depending on that username and password?

Thanks.
 
J

Jim Buyens

If you have a Windows Web server, set up a form with text
boxes named txtUser and txtPswd, and a submit button named
btnSub. Then, in Code view, add this code:
<%
if request("btnSub") <> "" then
if (request("txtUser ") = "top") _
and (request("txtPswd") = "secret") then
Session("loggedin") = "1"
response.redirect("privatepage.asp")
else
Session("loggedin") = "0"
response.redirect("publicpage.asp")
end if
end if
%>

For safety, you should also add this code to
privatepage.asp.

<%
if Session("loggedin") <> "1" then
response.redirect("publicpage.asp")
end if
%>

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
A

anonymous

If I were you I would use an include file for a session
check on every page beneath "privatepage", not just that
page, in order to prevent ANY access to subsequent pages.
 
J

Jim Buyens

anonymous said:
If I were you I would use an include file for a session
check on every page beneath "privatepage", not just that
page, in order to prevent ANY access to subsequent pages.

Fer sure, but the original question concerned only a single protected page.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------

 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top