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

Access only from main page

Status
Not open for further replies.

Cris

Programmer
Nov 29, 2000
16
0
0
ES
How I can control that the access to my Web is only possible from the main page?
Thanks
 
You can set a cookie like jaredn said, however, I believe it works better to put in an include file. Make an .asp page that checks for a member flag, first set it in the loginDone.asp...

<%
' LoginDone.asp - to verify the user's name and password.
' Once checked, and validated, set a session variable
' called memberFlag to true, then check for it in all your
' pages. Example...

dim uID, uPW, sql
uID = request.form(&quot;usersID&quot;)
uPW = request.form(&quot;usersPW&quot;)
sql = &quot;select userID, userPW, userFname, userLname FROM userTable WHERE (((userTable.userID)='&quot; &amp; uID &amp; &quot;') And ((userTable.userPW)='&quot; &amp; uPW &amp; &quot;'));&quot;

' open db connection and recordset connection here where
' rs = recordset

if not rs.eof then
session(&quot;userID&quot;) = rs(&quot;userID&quot;)
session(&quot;userPW&quot;) = rs(&quot;userPW&quot;)
session(&quot;userFirst&quot;) = rs(&quot;userFname&quot;)
session(&quot;userLast&quot;) = rs(&quot;userLname&quot;)
'And here you set the memberFlag
session(&quot;memberFlag&quot;) = True
response.redirect(&quot;afterLogin.asp&quot;)
else
session(&quot;memberFlag&quot;) = False
response.redirect(&quot;noAccess.asp&quot;)
End If

' End recordset and connection
%>



'Now create another page, for access verifying
<%
'checkAccess.asp
if session(&quot;memberFlag&quot;) not true then
session.abandon
response.redirect(&quot;noAccess.asp&quot;)
End if
%>


Now, the only other thing you need to do is include the page you just made.
------------somePage1.asp--------------------------
<!-- #include file=&quot;checkAccess.asp&quot; -->
<%
dim i, j, old
etc,
etc,
etc,

'this is your page after you login, and every other page.
%>
Now when someone types in a URL for &quot; it redirects them to 'noAccess.asp' because they never had their session variable &quot;memberFlag&quot;(which you can obviously call any name since it is a variable!)...set to true.

any q's, email me at jimbob550@hotmail.com

Jim
 
I'll try it. Thank you ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top