1
   

Sending the Referring Page Via E-mail

 
 
Reply Tue 26 Aug, 2003 12:45 pm
Hmm, this is my script so far:

Code:// set the TO: email address
$to = '*********@cox.net';

// set the SUBJECT: e-mail
$subject = "An error has occured - type: $error_code";

// set the MESSAGE: e-mail
$message = "The following error has occured:\r\n"

."--------------------------------\r\n\r\n"
." Type: $error_code\r\n"
." Page: {$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}\r\n"
." Time: ".date('d/m/Y H:i:s')."\r\n"
." Referring Page: $referred_by = ( isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'Unknown' )\r\n"
." From IP: {$_SERVER['REMOTE_ADDR']}\r\n\r\n"
."Regards,\r\n"
."Your hard-working web server.";

$headers = "From: webserver@{$_SERVER['SERVER_NAME']}\n"
."Reply-To: webserver@{$_SERVER['SERVER_NAME']}\n"
."X-Mailer: PHP/".phpversion();

// send the email
mail( $to, $subject, $message, $headers );


Referring page of couse is being called as
Code:Referring Page: $referred_by = ( isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'Unknown' )


What have I done wrong?
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 1 • Views: 1,567 • Replies: 5
No top replies

 
BobbyDouglas
 
  1  
Reply Tue 26 Aug, 2003 12:46 pm
Referring Page: = ( isset() ? : 'Unknown' );

Is what appears in the e-mail.....
0 Replies
 
Craven de Kere
 
  1  
Reply Tue 26 Aug, 2003 12:59 pm
Use this code and it will work.

Code:<?php

// Begin PHP Code

// FILENAME: FUNCTIONS.INC.PHP
function is_reported()
{

// SET THE DOMAIN NAME BELOW (without the 'http://' or 'www' bits)
$domain = 'able2know.com';

// ---------------------------------------------------------------

if( isset($_COOKIE['http_errors']) )
{
$_COOKIE['http_errors'] = unserialize( base64_decode($_COOKIE['http_errors']) );

if( in_array($_SERVER['REQUEST_URI'], $_COOKIE['http_errors']) )
{
// this error page / url has been reported by this person before
return TRUE;
}
}
// this person has either NEVER reported an error before
// or this is a NEW url error to report
$_COOKIE['http_errors'][] = $_SERVER['REQUEST_URI'];
$value = serialize( $_COOKIE['http_errors'] );
setcookie( 'http_errors', base64_encode($value), time() + 24*60*60, '/', '.'.$domain, 0 );
unset( $domain, $value );
return FALSE;
}

function send_error_email( $error_code='Undefined' )

{
if( !is_reported() )
{
// set the TO: email address
$to = '[email protected]';
$referred_by = ( isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'Unknown' );


// set the SUBJECT: e-mail
$subject = "An error has occured - type: $error_code";

// set the MESSAGE: e-mail
$message = "The following error has occured:\r\n"

."--------------------------------\r\n\r\n"
." Type: $error_code\r\n"
." Page: {$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}\r\n"
." Time: ".date('d/m/Y H:i:s')."\r\n"
." From IP: {$_SERVER['REMOTE_ADDR']}\r\n\r\n"
." Referring Page: $referred_by \r\n"
."Regards,\r\n"
."Your hard-working web server.";

$headers = "From: webserver@{$_SERVER['SERVER_NAME']}\n"
."Reply-To: webserver@{$_SERVER['SERVER_NAME']}\n"
."X-Mailer: PHP/".phpversion();

// send the email
mail( $to, $subject, $message, $headers );
}
}
// End PHP Code
?>
0 Replies
 
Craven de Kere
 
  1  
Reply Tue 26 Aug, 2003 01:00 pm
Re: Sending the Referring Page Via E-mail
BobbyDouglas wrote:

Referring page of couse is being called as
Code:Referring Page: $referred_by = ( isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'Unknown' )


What have I done wrong?


You needed to just set that variable outside of $message and just call it, see the code I posted. I tested it and it works.
0 Replies
 
BobbyDouglas
 
  1  
Reply Tue 26 Aug, 2003 01:37 pm
Woohooo. It works now. You can see the updated Generator on the site Laughing
0 Replies
 
Craven de Kere
 
  1  
Reply Tue 26 Aug, 2003 01:40 pm
Great! When I add more to this code I'll let you know. Eventually I'll flitch the generator from you. ;-)
0 Replies
 
 

Related Topics

Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » Sending the Referring Page Via E-mail
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/26/2024 at 12:44:59