OK, for this, the best solution would be to use ajax [or an iframe, if you're desperate].
First page, page.php, where the object to be click will be:
Code:
<html>
<head>
var http_request = false;
function makeRequest(url, parameters) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
http_request.onreadystatechange = alertContents;
http_request.open('POST', url + parameters, true);
http_request.send(null);
}
</script>
</head>
<body>
<?php $ip = $_SERVER[REMOTE_ADDR]; ?>
Button:<br />
<input type="button" value="Click here" onClick="makeRequest('get.php', '?IP=<?=$ip ?>');">
Link: <br />
<a href="javascript:makeRequest('get.php', '?IP=<?=$ip ?>');">Click here</a>
Next, use the page to process the req [req.php]::
PHP Code:
<?php
$ip = $_GET['ip'];
$today_date = date("Y-m-d");
mysql_query("INSERT INTO `ip_table` (`ip`,`timestamp`) VALUES ('".$ip."','".$today_date."')");
?>
It's pretty simple and straight forward, make changes at will.
HTH
Bookmarks