CodeAve.com CodeAve.com - ASP - Server Variables
ASP
·Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·Articles
·Miscellaneous
·Contents
·What's New?
JavaScript
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


404 Error Page (With a Db an IP Capture)
The basic 404 error or file not found page serves two specific purposes.  Firstly, to alert the user that the item they were expecting is not currently available, rather than the generic page your host may provide or worse the generic windows file not found page.  Secondly, to alert the webmaster that a file is missing or a link is targeting something incorrectly.  In order to provide users with a page that will show up whenever a 404 error occurs you need to change the settings on your web server to target a specific page or contact your hosting company to do this for you.  Once setup, the location of any file that is requested and not found on the server will be made available as a query string value and can be outputted to a database to track where and when the erros are occuring. A demonstration of the CodeAve.com 404 error page can be seen by clicking here.  (Some examples of other 404 error pages:  Yahoo!, Excite, Disney, NBC, Bloomberg)
View the Output
Text View
Print View
Mail this Link
Download the Code

<%
dim ip,referer,agent,q_string,accessdb,rs,cn,sql

' Varible for the PC IP address
ip=request.servervariables("remote_addr")

' Varible for the referring page to the error
referer=request.servervariables("http_referer")

' Varible for agent making the request
' (This will tell you what type of browser and other details)
agent=request.servervariables("http_user_agent")

' Varible for the querystring value (bad request)
q_string=request.servervariables("query_string")


' name of the db that will track the errors
accessdb="404.mdb" 

' Build a connection to the db
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)

' Create a server record set object
set rs = server.createobject("ADODB.Recordset")

' SQL statement that will insert the url and the ip address
sql = "insert into 404 (ip,referer,request,agent) "
sql= sql & "values('"& ip &"','"& referer &"','"& replace(q_string,"404;","") &"','"& agent &"')" 

' insert the values into the db
rs.open sql, cn

%>

<html>
<title>404 Error Test Page</title>
<body bgcolor="#FFFFFF">
404 Error test Page<br>
The page you were looking for <br>
<i><%= replace(q_string,"404;","") %></i> <br>
could not be found. 

<%
' if there was a referering page 
' place a link to go back
if referer <> "" then
%>

Click <a href="javascript:history.back()">here</a> 
<br>
or the back button to go to the previous page
<% end if 'end check for referer %>
</body>
</html>


<%
' kill the recordset 
set rs=nothing
' kill the connection 
set cn=nothing
%>

 

 

 



ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement

    CodeAve.com is hosted by MyHosting.com
    Donate Food Online with a Mouse Click at TheHungerSite.com
    Donate Land Online with a Mouse Click at TheRainForestSite.com
    © 1999 - 2017 CodeAve.com
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3