Problem with: $ip_Address = $_SERVER['REMOTE_ADDR'];
Posted: Sun Nov 03, 2002 12:05 pm
I am trying to build some secure checking into a login script that I use as an include at the start of each page in a members area and can't seem to get a value returned for $ip_Address, but if I use the code as: I get an address returned, can anyone see what I'm doing wrong here? the include script is as follows:
Code: Select all
<?php
$ip_Address = $_SERVERї'REMOTE_ADDR'];
echo "$ip_Address";
?>Code: Select all
<?php
session_start();
$goLogin = "./userlogin.php";
$ip_Address = $_SERVERї'REMOTE_ADDR']; // NO VALUE RETURNED
#
########################### - CHECK THE IP ADDRESS IS THE SAME AS THE USERS AND THE VARIABLES ARE SET FOR THE SESSION
#
# - Check if the IP Address is set but it is not that of the session
$notHighjacked = isset($_SESSIONї's_ipAddress'])
&& ($_SESSIONї's_ipAddress'] = $ip_Address);
# - Check if all the session variables are set
if ($notHighjacked && isset($_SESSIONї's_ipAddress'])
&& isset($_SESSIONї's_c_login'])
&& isset($_SESSIONї's_client_ID'])
&& isset($_SESSIONї's_c_password'])) {
$authorized = true;
}
# Check if the $highjack flag is true or the $authorized flag is false
if(!$notHighjacked) {
# - The request did not originate from the machine that was used to create the session
// email code here
$logintext = "You are not authorized to access this area, your IP address of " . $ip_Address . " has been recorded."; // NO VALUE RETURNED FOR $ip_Address
($_SESSIONї'logintext'] = $logintext);
// Relocate back to the login page
header("Location: " . $goLogin);
exit;
}
else if(!$authorized)
{
// The user has not logged in
$logintext = "You need to log in.";
($_SESSIONї'logintext'] = $logintext);
# RELOCATE BACK TO THE LOGIN PAGE
header("Location: " . $goLogin);
exit;
}
# - ALL IS OK SO LET THE USER IN
?>