Page 1 of 1

A little help with my counter

Posted: Fri Sep 27, 2002 9:01 am
by waskelton4
Hey group..

I've got a few questions...

I'm bulding a counter for my website and know what i'd like to have it do and know how i'd like to implement it, but i guess i need to know if what i want to do can actually be done..

What i'm wanting to do is buld some code, with PHP and JS, that serves as a counter for the web page..

What i'd like to do is "install" it in each web page by simply including the counter files in the code.

ie..

Code: Select all

<script language="javascript" src="getSpecs.js"></script>

<?
include(counter.php);
?>
Where the js file gets some browser specific data an the php file actually does some checking and logs the page load into mySQL.

From what i've been reading i'm not sure that this is possible because in order to actually get the js data to counter.php i'll have to submit the js data somehow..

is that what i'm looking at? Would it be better to log the js data on the next page loaded and send a page identifier along with the data telling mySQL where to put the js data?

any advice would be greatly appreciated..

also, if that makes no sense.. please let me know :)

Thanks
Will

Posted: Fri Sep 27, 2002 9:09 am
by volka
javascript is (mostly) performed client-side while php is (almost all the time) done serverside.
if your page is provided via a php-able server the client will only 'see'

Code: Select all

<script language="javascript" src="getSpecs.js"></script> 

<- output from counter.php->
you have to send the results from getSpecs.js within a new request.

always remember: when a http-document is served, it's served and the connection (from http's point of view) is dead.

Posted: Fri Sep 27, 2002 9:28 am
by nielsene
But I think you could use the js code to set hidden variables that the php script will use on the receiving page. Alternative the js code add parameters to URL, set cookies (I think) etc with the values you want...
Of course this means that your counter lags one page view (ie the values that the determines are only entered into your database when the user views the next page.)

Posted: Fri Sep 27, 2002 9:36 am
by volka
"Where the js file gets some browser specific data" <- what data do you think of?
Maybe the browser is sending those values freely (version, etc.)

Posted: Fri Sep 27, 2002 9:45 am
by waskelton4
From volka:
Where the js file gets some browser specific data" <- what data do you think of?
Maybe the browser is sending those values freely (version, etc.)
Primarily screen resolution and color depth...
I also want to kind of experiment with the differences between navigator.appName and $_SERVER['HTTP_USER_AGENT']

if navigator.appName provides names for enough browsers then i probably won't mess with getting the browser names out of $_SERVER['HTTP_USER_AGENT']
Thanks for the help.
will

Posted: Fri Oct 04, 2002 10:21 am
by CodeEye
it is possible to send a message back from the browser if it is dom compliant check out
http://www.dotvoid.com/article_condensed.php?itemID=9

you will only need to updat it once so you can get rid of the timer