[nycphp-talk] javascript calling php function -- now question on Ajax
Ken Robinson
kenrbnsn at rbnsn.com
Tue Feb 19 07:25:17 EST 2008
At 11:58 PM 2/18/2008, Susan Shemin wrote:
>thanks, Mike and Ken
>
>first off, I'm not using a form (so no POST); the link is in an
>anchor tag. I could put a form around it, but that seems to me
>making a simple link complex.
You don't understand. The POST method is defined in the AJAX code you
write, it has nothing to do with having a form or not.
>
>I want to run this php code when the link is clicked
>
> $webpage="";
> $link_clicked="";
>
>Function capture_click($webpage,$link_clicked)
>{
> $entry_date=date("m-d-y-H-i");
>
> $sql = "INSERT INTO click_details " .
> "SET webpage='$webpage', link_clicked='$link_clicked',
> entry_date='$entry_date'";
> $ok = mysql_query($sql);
> if ($ok) {
> //error checking
> }
>}
>?>
>
>and then the anchor text (or how I guessed would work)
>
><a href=www.nyphp.org onclick="<?php
>capture_click(name_of_my_webpage,link_name); ?>";>info on PHP</a>
But, Austin, is correct, you don't need AJAX here.
Ken
More information about the talk
mailing list