You are here: Re: PHP and Ajax « PHP Language « IT news, forums, messages
Re: PHP and Ajax

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация