ok here it goes.

I found a bunch of scripts online that do kind of what I want, but not exactly.
so i copied and pasted what i wanted from those scripts and put them together into one script. of course it does not work at all now haha.

probably just a syntax issue but i cant figure it out. i am still a php noob.

what i am trying to do is make the script determine if they have visited before based on the users ip address.

If they have visited for the very first time, they will see a picture displayed.
if they have already visited then it will redirect them.

here is the broken code
it does not log ip, it does not redirect, and it does not show picture.
everything about it is broken. you would think there would already be a working script template available online but i could not find one that does exactly what i want.

//get their ip address
    if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
    else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
    else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
    else $ip = "";  
//read the log file and check it against their ip and redirect if they match then exit script.
$file = fopen("ips.txt", "r");
while (!feof($file)) {
   $line = fgets($file);
if ($line = $ip) 
header( 'Location: http://www.yoursite.com/new_page.html' );
//if there is no match, add their ip to the list
$file = "ips.txt"; //Select file
$file = fopen($file, "a"); //Appened file
fwrite($file, $ip); //Write ip to file
fclose($file); //Close the file
//then show a picture
header('Content-Type: image/jpeg');