ok now i'm tottaly confused...
here's my test script that works fine and if http_referer is not from my domain the it displays the user ip:
if (isset($_SERVER['HTTP_REFERER'])) {
//the server he tried to execute the script
$referer=strtolower($_SERVER['HTTP_REFERER']);
if (!strstr($referer, 'mydomain.com')) {
//echo '<b>'.$referer.'</b>';
//Remote IP of the user
$remote_address = $_SERVER['REMOTE_ADDR'];
//The browser he used to connect
$user_browser = $_SERVER['HTTP_USER_AGENT'];
$date = date('j-n-Y @ H:i:s');
echo '<font face="verdana, arial" style="font-size: 11px; font-weight: bold">Your IP address is: </font><font face="verdana, arial" style="font-size: 13px; font-weight: bold; color: red">'. $remote_address .'</font><br><br>';
}
else {
echo 'EVERYTHING IS OK!';
}
}
And here's the code I use at my site. For some reason this code doesn't look for http_referer even though it's the same as the above! If you could help I'll be very greatful:
session_start();
require 'includes/config.php';
if(isset($_SERVER['HTTP_REFERER'])) {
//the server he tried to execute the script
$referer=strtolower($_SERVER['HTTP_REFERER']);
if(!strstr($referer, 'mydomain.com')) {
//echo '<b>'.$referer.'</b>';
//Remote IP of the user
$remote_address = $_SERVER['REMOTE_ADDR'];
//The browser he used to connect
$user_browser = $_SERVER['HTTP_USER_AGENT'];
//$date = date('j-n-Y @ H:i:s');
echo '<font face="verdana, arial" style="font-size: 11px; font-weight: bold">Your IP address is: </font><font face="verdana, arial" style="font-size: 13px; font-weight: bold; color: red">'. $remote_address .'</font><br><br>';
}
else {
$pass = trim (htmlspecialchars (addslashes ($_POST['Login'])));
$login = trim (htmlspecialchars (addslashes ($_POST['Member'])));
//$pass = $_POST['Login'];
//$login = $_POST['Member'];
$sql_username_check = mysql_query("SELECT memb_id FROM members WHERE memb_id='$login' AND memb_pwd='$pass'");
$username_check = mysql_num_rows($sql_username_check);
$sql_pass_check = mysql_query("SELECT memb_pwd FROM members WHERE memb_pwd='$pass' AND memb_id = '$login'");
$pass_check = mysql_num_rows($sql_pass_check);
if (empty($login) || empty($pass) || ($username_check <= 0) || ($pass_check <= 0)) {
echo '';
if (empty($login) || empty($pass))
echo '<b>Error: <br>Some fields were left blank. Please go back and try again.</b>';
elseif (($username_check <= 0) || ($pass_check <= 0))
echo '<b>Error:<br>Bad Username / Password. Please go back and try again.</b>';
}
else
{
$_SESSION['login'] = $login;
$_SESSION['pass'] = $pass;
}
if ($_SESSION['login'] == TRUE ) {
$sql = mysql_query("SELECT mail_addr FROM members WHERE memb_id='$login'");
$mailsession = mysql_result($sql, 0, 0);
$_SESSION['mailsession'] = $mailsession;
echo 'Successfully logged in. You are being redirected...
<meta http-equiv="refresh" content="0; URL=index.php?op=account.php">';
}
}