PHP - Comparing strings with strpos
<p>I have set up a polling system on my website. However to ensure that people cannot vote again, I have a IP finding mechanism to gather their IP and to make sure that they do not vote again.</p>

<p>The way in which i do this, is I gather their IP then compare it to a text file which has the IP in it. It has a comma to separate each IP.</p>

<pre><code>function getUserIP()
{
//check ip from share internet
if (!empty($_SERVER['HTTP_CLIENT_IP']))
{
  $ip=$_SERVER['HTTP_CLIENT_IP'];
}
//to check ip is pass from proxy
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
  $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
  $ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}

$visitorIp = getUserIP();
$myFile = "ip_polllist.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, 200);
fclose($fh);
$findme = $visitorIp.",";
$mystring = $theData;
echo $mystring;
echo $findme;
$pos = strpos($mystring, $findme);
if($pos === true)
{
    die();
}
if($pos == true)
{
die();
}
</code></pre>

<p>What is wrong with the code and why does <code>$pos = false</code>?</p>
