Forum Moderators: coopster
@$result = mysql_query($querit) or die('no access!';
$ipaddr = isset($_SERVER['REMOTE_ADDR']) ? preg_replace("/[^.:()a-zA-Z0-9\/]/", "", $_SERVER['REMOTE_ADDR']) : '';
mail('me@example.com','script.php attempt','access attempt by '.$ipaddr,'headers','parameters'));
function my_exit($email,$from,$the_query,$the_ip,$sql_err) {
$subject = 'This is the subject, probably better passed as a parameter';
$headers = "From: $from\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = "
<p>Access attempt by $from IP address $the_ip</p>
<p></p>Query used: $the_query</p>
<p>mySQL error $sql_error</p>
";
mail($email, $subject, $message, $headers);
echo "<p>An error has occurred, please contact us.</p>";
exit;
}