Page 1 of 1

post data on load

Posted: Fri Feb 10, 2006 5:00 am
by ed209
Hi,

I have some static html pages that I want to keep the number of views they receive.

All I need to do is pass back the ID of the page which will be written into the page when it is saved.

At the moment I have an onload event in the body tag that calls the following javascript:

Code: Select all

function sendData(advert_id){
		var url="my_db_update_file.php?pv=" + advert_id;
	       window.open(url, "_self");		
	}
and the PHP page that I'm posting back to looks like this:

Code: Select all

<?php

	class dbConnect{
		/**/
		var $server="localhost";
		var $user="user";
		var $password="password";
		var $database="database";
	}
	$dbclass = new dbConnect;
	
	mysql_connect($dbclass->server,$dbclass->user,$dbclass->password);
	mysql_select_db($dbclass->database);
	
	// update the stats
	$add = mysql_query('INSERT INTO `test` (`id`,`passed_val`) VALUES ("","'.$_GET['pv'].'")');
	
	mysql_close();
	

?>
The trouble is, I think the javascript is reloading the page with a blank one. Is it possible to load an html page and execute a php page and passing it some variables? (without loosing / reloading the current html page)

Thanks

Posted: Fri Feb 10, 2006 8:20 am
by feyd
What about using the Javascript detection thing I posted a while back?

viewtopic.php?t=42557