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

a simple question

Status
Not open for further replies.

maesb

Technical User
Mar 25, 2003
30
JP
hi,
this question may sound a bit silly.
how do i redirect user to a mainpage.asp when user enters my link for example, ?
thanks..
 
Hi barramu,

Here is copy of a login validation page I use for our local scouts.
It's actually html & asp combined. Didn't know a thing about asp when I started this website for our scouts! Like many others, I tried using the built in features of Access 2000 for web pages. Not aware of the many issues that will arise if a user outside the network tries to use your web pages! Which really ticked me off, spent weeks developing in Access, only to scrape the entire project!

This is ONE page! Notice the Two <HTML> Tags!

Code:
<%Response.Buffer = True%>
<HTML>
<HEAD>
<%
Dim strRemoteIP
strRemoteIP =  LCase(Request.ServerVariables("REMOTE_ADDR"))    ' Client's IP address
%>
<TITLE></TITLE>
</HEAD>
<BODY>
<%
' Open a DNS-Less connection to the database
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Data Source=" & Server.Mappath("scouts.mdb") & ";Provider=Microsoft.Jet.OLEDB.4.0;"
set rs = Server.CreateObject("ADODB.Recordset")

' Setup the JOINS, and the relationship within the tables
sql="SELECT tblUsers.UserID, tblUsers.Login, tblUsers.Password "
sql=sql & "FROM tblUsers "
sql=sql & "WHERE tblUsers.Login=" & Chr(34) & Request.Form("Name") & Chr(34)
sql=sql & " AND tblUsers.Password=" & Chr(34) & Request.Form("Password") & Chr(34)
rs.Open sql, conn
On ERROR RESUME NEXT
If rs.recordcount <> 1 Then
'Set a log file - give it a 1 hour life
If Request.Cookies("status") = "" Then
  Response.Cookies("status")= 1
  Response.Cookies("status").Expires=DateAdd("h",1,Now)
Else
  Response.Cookies("status")= Request.Cookies("status") + 1					
  Response.Cookies("status").Expires=DateAdd("h",1,Now)
End If
End If

'Determine if we ban the IP address
If Request.Cookies("status") > 3 Then 'Wrong Password or Name supplied, Ban the address
    Set connupdate = Server.CreateObject( "ADODB.Connection" )
    Set rec = server.CreateObject("ADODB.Recordset")
    'Create connection to the table, and use OLEDB.4.0 driver
    connupdate.Open "Data Source=" & Server.Mappath("scouts.mdb") & ";Provider=Microsoft.Jet.OLEDB.4.0;"
    dim objRS
    set objRS = server.CreateObject("ADODB.Recordset")
   ' Set the cursor location to client side (3)
    objRS.CursorLocation = 3
    objRs.open "Select * from tblBannedIP where RecordID = 0", connupdate, 3, 3
    objRS.AddNew
    objRS.Fields("IP") = strRemoteIP
    objRS.Update
    objrs.Close
set objrs = Nothing
connupdate.Close
set connupdate = nothing[COLOR=green]
MyRedirect = "/62/banned.asp"
Else
MyRedirect = "/62/scouts.asp"[/color]
End If

'Set a Cookie to the User ID, Bypasses Login  - give it a 1 day life.
If rs("UserID") <> 0 Then
  MyID = rs("UserID")
    Response.Cookies("Scout-No")=MyID
    Response.Cookies("Scout-No").Expires=DateAdd("d",1,Now)
End If
rs.Close
set rs = Nothing
 conn.Close
set conn = nothing

%>
</BODY></HTML>[COLOR=green]
<html>
<head>
<title>Re-Direct to Scout Pages</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
redirTime = "3000";
redirURL = "<%=MyRedirect%>";
function redirTimer() { self.setTimeout("self.location.href = redirURL;",redirTime); }
//  End -->
    </script>
</head>
<body onLoad="redirTimer()">
<div align="center"><h2>
	Please Wait</h2><br>
	<br>Processing your Login<br>
	<br>You will be Re-Directed to your Scout page in a few seconds.
	<br>If you are not re-directed in a few seconds, try clicking below.
	<br>
	You may also get there by clicking
	<a href="/62/scouts.asp"
		ONMOUSEOVER="window.status='Return to your scout page'; return true;"
		ONMOUSEOUT="window.status=''; return true;">here</a><br>
	</div>
	<br><br>
</body>
</html>
[/color]

The code in green, is processed last! And is probally all you need to add. I added the entire code for a reference.

Hope this helps!

Carl

AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top