Jump to content


Recommended Posts

Sorry, it was PHP not JavaScript. I have used it in my 404 error page to let me know when there is an error on my site. You may be able adapt it for your use. It would be placed in each page you wanted to alert you.


You can find that script here: h**p://shat.net/php/404/404Handler.php.txt

Link to comment
Share on other sites

I've modified that script to send an email when a page is loaded. Copy the script below and place it in any web page before the opening tag. Make sure there is not a blank line ahead of this script. Be sure to change the lines to contain your domain and email address of where to send the email.


//portions of this script are originally from shat.net
//the remainder modified by Bruce Richards
# Set $domain to your domain name (no www)
$domain = "your-domain.ext";
# Set $docroot to the URL of the directory which contains your
# .htaccess file. Don't include trailing slash.
$docroot = "http://www.your-domain.ext";
# Set $emailaddress to the email address of whoever should be
# notified. Don't escape the @ symbol.
$emailaddress = "someone@your-domain.ext";

//--------all done for customizing script------
function send_email() {
//this function originally from this script:
# Copyright 2000-2002 shaun@shat.net under the GPL v2+
# Request access to the global variables we need
global $REQUEST_URI, $HTTP_REFERER, $emailaddress, $REMOTE_ADDR, $docroot;
# Build the $errortime variable to contain the date/time of the error.
$errortime = (date("d M Y h:m:s")); 
# Create the body of the email message
$message .= "Page Hit Report\n\nThe page $docroot$REQUEST_URI\n\n";
$message .= "was just accessed by $REMOTE_ADDR\n\n";
$message .= "The referring page was:\n$HTTP_REFERER\n\n";
# Send the mail message. This assumes mail() will work on your system!
$headers = "From: $emailaddress\nDate: $errortime -0600\n";
$subject = "Page Hit: $docroot$REQUEST_URI";
mail($emailaddress, $subject, $message, $headers);

//send an email with the info


You can modify the message being sent. It will show the page (link) that was accessed, what page (link) referred it and the IP address of the visitor.


Hope that helps.

Link to comment
Share on other sites

you could always load the IP into a log database table and do a cron job every so often to email you the latest visitors...


If you get a lot of visitors to a certain page you are going to get a lot of emails


Why do you want to know the IP's of those accessing the page though? What are you planning to do with that data?

Edited by OJB
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...