- ASP - Server Variables
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·What's New?
Mail List


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 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

' Varible for the referring page to the error

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

' Varible for the querystring value (bad request)

' name of the db that will track the errors

' 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 sql, cn


<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> 
or the back button to go to the previous page
<% end if 'end check for referer %>

' 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 is hosted by
    Donate Food Online with a Mouse Click at
    Donate Land Online with a Mouse Click at
    © 1999 - 2018
    All Rights Reserved

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