the-dream
01-13-2008, 08:10 PM
Hey Guys,
First off I didn't quite know if this belonged in the JavaScript Forum or the PHP one so please move it if it is wrong!
I am creating a visitor counter and i want to know how I can execute a page of PHP from JavaScript.
Here is the PHP page:
<?php
require_once('../Connections/dreamstats_db.php');
$colname_RSTrack = "-1";
if (isset($_GET['id'])) {
$colname_RSTrack = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_dreamstats_db, $dreamstats_db);
$query_RSTrack = sprintf("SELECT * FROM pages WHERE id = %s", $colname_RSTrack);
$RSTrack = mysql_query($query_RSTrack, $dreamstats_db) or die(mysql_error());
$row_RSTrack = mysql_fetch_assoc($RSTrack);
$totalRows_RSTrack = mysql_num_rows($RSTrack);
$id = $_GET['id'];
$visit = $row_RSTrack['visits'] + 1;
$result = mysql_query("UPDATE pages SET visits='$visit' WHERE id='$id'");
mysql_free_result($RSTrack);
?>
I want to execute that (track.php) from some JavaScript. It needs to be able to do on multiple domains. For example, track.php is on domain.com and I want to put the JavaScript to execute the code on example.com! These pages won't be .php they will most likely be .html/.htm! I really have no idea how to do this, hoping someone out there knows how!
Thanks a million!
~ Christian
First off I didn't quite know if this belonged in the JavaScript Forum or the PHP one so please move it if it is wrong!
I am creating a visitor counter and i want to know how I can execute a page of PHP from JavaScript.
Here is the PHP page:
<?php
require_once('../Connections/dreamstats_db.php');
$colname_RSTrack = "-1";
if (isset($_GET['id'])) {
$colname_RSTrack = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_dreamstats_db, $dreamstats_db);
$query_RSTrack = sprintf("SELECT * FROM pages WHERE id = %s", $colname_RSTrack);
$RSTrack = mysql_query($query_RSTrack, $dreamstats_db) or die(mysql_error());
$row_RSTrack = mysql_fetch_assoc($RSTrack);
$totalRows_RSTrack = mysql_num_rows($RSTrack);
$id = $_GET['id'];
$visit = $row_RSTrack['visits'] + 1;
$result = mysql_query("UPDATE pages SET visits='$visit' WHERE id='$id'");
mysql_free_result($RSTrack);
?>
I want to execute that (track.php) from some JavaScript. It needs to be able to do on multiple domains. For example, track.php is on domain.com and I want to put the JavaScript to execute the code on example.com! These pages won't be .php they will most likely be .html/.htm! I really have no idea how to do this, hoping someone out there knows how!
Thanks a million!
~ Christian