Web Hosting Talk







View Full Version : Need php code help


kickmybutt
12-16-2003, 12:17 AM
OK, I have fought and fought.... but the code that I have written just isn't working...

I have a login page. When someone accesses it, it writes their IP to a .txt file, easy enough. But what I need is if they try to access it twice (wrong login twice) they are forwarded to a site (off site if I choose)

So, if login twice fails, send to www.yahoo.com

Any idea what I am missing??

Studio64
12-16-2003, 12:25 AM
how about ... paste the code you've written and we'll see what's wrong w/ it

kickmybutt
12-16-2003, 01:16 AM
uummm yea... Why dont I do that :)
I dont have anything at the moment.... here is what I was using.


$killuserurl = "http://yahoo.com";
$logfile = "ip.txt";
$file = fopen($logfile,"r+");
flock($file,2);
$count = fgets($file,filesize($logfile));
$wip = fgets($file,filesize($logfile));
print $count;

$ip = getenv("REMOTE_ADDR");

if($ip !== $wip)
{

$count = $count + 1;
rewind($file);
fwrite($file,$count."\n".$ip);
flock($file,3);
fclose($file);
if ( $count = 2 ) {
print $killuserurl\nURI: $killuserurl\n\n";

kickmybutt
12-16-2003, 01:17 AM
eerrr... after posting that I think I see my errors

Not sure... I will check...

ResellerMan
12-16-2003, 02:36 AM
if ( $count = 2 ) {
print $killuserurl\nURI: $killuserurl\n\n";


Should be changed to:


if($count == 2 )
{
print $killuserurl\nURI: $killuserurl\n\n";
}
}


Maybe you forgot to close that argument :?

ResellerMan
12-16-2003, 02:38 AM
Are you getting a PHP error?