SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2006
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How javascript write data to database?

    Those traffic statistics scripts like statcounter.com, hitlinks, all use javascript to collect the visitors information and then show to users via php/asp pages.

    So my questions is, how the data collected by javascript were written into database?

  2. #2
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The JavaScript statcounter uses is only to put an image on your website.
    When loading the image, statcounter probably servers the image with a PHP script, so they can log the visitor.

    Writing to a database with JavaScript is not possible, or I've just never seen someone do that.

    Grtz,
    Vince
    Last edited by hexburner; May 6, 2008 at 02:22.
    FOR SALE: 1 set of morals, never used, will sell cheap

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2006
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Statcounter use javascript to collect the traffic information for a website, and then display those information to users in php pages? Definitely those information are from its database. So how it can transfer the javascript collected data into statcounter's database?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,678
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Often it's done by requesting an image, where the image name has querystring information. That querystring information is then parsed from their logs and put into a database.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Enthusiast benno23's Avatar
    Join Date
    May 2008
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Although Javascript can not directly write to a database--it can dynamically call a server side script to do it without reloading the page via the xml http request.

  6. #6
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by benno23 View Post
    Although Javascript can not directly write to a database--it can dynamically call a server side script to do it without reloading the page via the xml http request.
    That could be pretty dangerous to do.

  7. #7
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,492
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Pepejeria View Post
    That could be pretty dangerous to do.
    If you do it like that, yes. But if you do it the right way, no. Like anything that has to do with user input.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •