Jump to content

Script redirect and pointer.


Ruud Hermans

Recommended Posts

<?php$IP=$_SERVER['REMOTE_ADDR'];$datum=date("l, F d, Y h:i" ,time());$fh=fopen("gegevens.txt","a");fwrite($fh,$datum,$IP);fclose($fh);?>

I wrote the bit of code you see above I would like some help on finishing it I need to foloowing 2 things done;1. reste the pointer to the top of the file gegevens.txt so each new hit is set on a new line.2. make it redirect to www.asite.com after writing the info to the file.Ruud Hermans

Link to comment
Share on other sites

If i am understanding what you want, then

$IP = $_SERVER['REMOTE_ADDR'];$datum=date("l, F d, Y h:i" );$fh = fopen("gegevens.txt","w");if(fwrite($fh,$dateum.$IP."\n")){fclose($fh);header("location : http://www.asite.com/");}

Link to comment
Share on other sites

Yeah, just add the new line return which is \n for a line break. Jhechts' script is bugged also, right here: if(fwrite($fh,$dateum.$IP."\n")){There is no variable called $dateum, its $datum

Link to comment
Share on other sites

Also, this line is wrong:$fh = fopen("gegevens.txt","w");It needs to be this:$fh = fopen("gegevens.txt","a");The 'a' mode is for appending, which places the new text at the bottom of the file. If you want the new text at the top of the file, then you will need to read the entire file into a string, prepend your text to the beginning of the string, and write the entire thing back. That will be more inefficient then appending though.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...