▼  Site Navigation Main Articles Search  ▼  Anime + Manga Anime Reviews Anime Characters Gallery Screenshots Manga Reviews  ▼  Misc News Links to Webcomics Bible Quotes About Older Musings
site version 7.3
PHP/Javascript –– store user's stats in a file
written by: admin

Date Written: 10/21/08 Last Updated: 8/20/10

$ipaddress = $_SERVER['REMOTE_ADDR'];
$screen_res = $HTTP_COOKIE_VARS["user_resolution"];
<script language="javascript">
function writeCookie()
var today = new Date();
var the_date = new Date("December 30, 2022");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
location = '/';
$today = date("Y-m-d");
$fh = fopen("test_text.txt","a");
fwrite($fh,"$ipaddress $screen_res $today \n");
echo "Your Screen resolution is set at ". $screen_res;
echo "<br>Your IP address is $ipaddress";
echo "<br>Today's date is $today";

This will detect the ipaddress, screen resolution, and create a file named test_text.txt where the stats are then stored.  If the file already exists then it will just update the file.

Here is a tiny sorting script I created to view the results.  $dates are the contents of the .txt file.
$text = implode("<br>",$text);
echo $text;

TAGS: javascript, php
copyright 2005–2023