|
Posted by Janwillem Borleffs on 12/04/05 13:09
jrd100 wrote:
> I am trying to write an web application using AJAX to track what link
> the user clicked to leave the website.
>
> The purpose of this is to have the embedded client-side XMLHttpRequest
> object call a php script when the user clicks a hyperlink. Then the
> php script gets the value from the query string, assigns this value to
> variable and updates a MySQL table.
>
> This is not working though. The php script ignores the GET request
> sent by the client-side XMLHttpRequest object.
>
You don't need to use "ajax" for this.
In ajax.html, just use a link like the following:
<a href="you.php?param=http://yo.com">Go</a>
And in yo.php, do something like:
$link = $_GET['param'];
// assume database connection
$dbh=mysql_connect ("localhost", "<un>", "<pwd>");
mysql_select_db ("<database>");
$query = "insert into sample (idx,link) values('','$link')";
$result = mysql_query($query);
header("Location: $link");
Advantage: Works in all browsers *without* JavaScript.
JW
Navigation:
[Reply to this message]
|