Results 1 to 3 of 3

Thread: PHP on 404 error page

  1. #1
    New Registered User james1987's Avatar
    Join Date
    Jul 2012
    Posts
    1

    Default PHP on 404 error page 30 Jul 2012 @ 13.08

    Ok, First off if this is in the wrong place please feel free to move it.

    I added a little drop of code to my 404 to see where the pages were failing and i'm now getting hundreds of emails the code i added to the page was
    PHP Code:
    <?php require_once("910363_Connections/loveit.php"); ?>
    <?php 
    include("header.php"); ?>
    <head>


    <meta http-equiv="refresh" content="10;url=http://www.loveitmagazine.co.uk/">
    <title>404 Error Page</title>
    </head>


    <body>
    <br />
    <br />
    <br />
    <br />
    <div align="center" style="color:White"><h1>404 Error</h1></div>
    <div align="center" style="color:White"><p>Whoops looks like you've turn too many pages! Or that theres been a mistake. Lets get you back on track our home page will load shortly.</p>


    </div> 
    <?php
    $url 
    $_SERVER"REQUEST_URI" ];
    $referrer $_SERVER"HTTP_REFERER" ];
    if ( 
    $referrer == "" )
    $referrer "Unknown";
    if (
    $url!= "/sitemap.rdf"
    && stristr($url'/_vti_bin/') == FALSE
    && stristr($url'/siteinfo.xml') == FALSE
    && stristr($url'/MSOffice/clt') == FALSE
    ){
    mail("webmaster@loveitmagazine.co.uk""Page Not Found",
    "Requested Page: " $url
    "\r\nReferred By: " $referrer
    "\r\nRemote Addr: " $_SERVER["REMOTE_ADDR"] . " (" $_SERVER["REMOTE_HOST"] . ")"
    "\r\n"
    "\r\nRequest URI: " $_SERVER["REQUEST_URI"]
    "\r\n"
    ,"From: [email]webmaster@loveitmagazine.co.uk[/email]" );
    }
    ?> 
    </body>
    </html>
    Its all working great appart from im getting 100's of emails with this or similar stating the requested site is the 404 page?:-

    HTML Code:
    Requested Page: /404.php
    Referred By: [url=http://www.loveitmagazine.co.uk/stories_form.php]Love It Online! Celeb gossip, recipes, fashion, beauty and real life stories![/url]
    Remote Addr: 197.15.81.160 ()
    Request URI: /404.php
    i dont know why this causing this error any help or suggestions would be lovely!
    Last edited by Frinkky; 30 Jul 2012 at @ 13.58. Reason: php/html tags
      Reply With Quote

  2. #2
    Senior Member Mike Hopley's Avatar
    Join Date
    Jul 2009
    Posts
    671

    Default 30 Jul 2012 @ 13.55

    In your code, the "requested page" and "request uri" are both set to $_SERVER["REQUEST_URI"], which is "the URI which was given in order to access this page". Therefore you'd expect it to be the 404 page.

    Wouldn't it be simpler to track this using error logs or analytics?
      Reply With Quote

  3. #3
    New Registered User ksushil970's Avatar
    Join Date
    Aug 2012
    Posts
    1

    Default 5 Oct 2012 @ 12.02

    I agree with you mike... in this code this is the major problem.
    Last edited by WelshStew; 5 Oct 2012 at @ 14.25. Reason: do not force signature
      Reply With Quote

Tags for this Thread

Posting Permissions

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