Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Error Reporting

  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    161
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Error Reporting

    In my error pages for my site I've added some code to send me an E-mail with the HTTP_REFERRER if it is set. It's pretty simple but it more or less does the job for me. This is it:

    Code:
    <?php
    $domain = $_SERVER["HTTP_REFERER"];
    if (isset($domain))
    {
    	if (!empty($domain))
    	{
    		mail("joe@example.com", "Error 404", "A 404 came from $domain", "From: error@myserver.com");
    	}
    }
    ?>
    Is there any way I could detect the page they were trying to access?

    E.g. "A 404 came from [HTTP_REFERRER] linking to [URL OF MISSING PAGE]" that would just save me going through the whole page trying to figure out what is causing the error. I got 4 messages all dated the same today giving 404s from my homepage and I can't find any broken links

    Knowing what they were trying to access would make it a lot easier to identify the problem.

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    You could use $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_FILENAME']
    [ot]
    hehe a post I got a chance to answer instead of raf
    [/ot]

  • #3
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    You may also want $_SERVER['QUERY_STRING']

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Nightfire
    You could use $_SERVER['PHP_SELF'] or $_SERVER['SCRIPT_FILENAME']
    [ot]
    hehe a post I got a chance to answer instead of raf
    [/ot]
    Already made a formal complaint to my ISP for the downtime today...
    Back OT --> can't you just check your webservers logfile. This will give you all the info you need + there are a lott of logfile anaylising tools to transform these logs into the form you need them
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #5
    Regular Coder
    Join Date
    Nov 2002
    Posts
    161
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I use a web host and all I get is webalizer details and it doesn't really tell me enough. I don't know much about that. There is a directory in my hosting account called statistics but I get permission denied trying to open it.

    Surely using PHP_SELF would not work. The E-mail could be "A 404 came from [HTTP_REFERRER] linking to [URL OF MISSING PAGE]" but surely if I used PHP_SELF the URL of missing page would come through as 404.php no???


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •