• # August 14, 2009 at 1:15 am

    I have a variable that I want to send to another file to be echoed out to the screen. I tried sessions but no luck. I was searching and the searches say to use GET or POST but they aren’t working either. I don’t get anything when I try it, but then it could be wrong code. I have a hit counter that I am working on. The idea is to get the number from a file and then send that number to a different page to be seen. I want it like this so that no one else but me can see the numbers. Here is the hit counter that works. This will display the number to the screen if you make an index.php and an empty file called reader.txt.

    $filename= “reader.txt” ;

    $fd = fopen ($filename , “r”) or die (“Can’t open $filename”) ;

    $fstring = fread ($fd , filesize ($filename)) ;

    echo “$fstring”;

    fclose($fd) ;

    $fd = fopen ($filename , “w”) or die (“Can’t open $filename”) ;

    $fcounted = $fstring + 1 ;

    $fout= fwrite ($fd , $fcounted ) ;

    fclose($fd) ;

    I don’t know why the code is written this way, I have been following a tutorial. What I want to do is be able to use $fstring in another page. I want to be able to include this code in one page without it showing the results on that particular page. I think this makes sense.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.