Jump to content

call a php from onclick event


n8w

Recommended Posts

objective: I want to track outbound links using the event [b]onclick[/b]

currently, I am doing using a form that goes to a script called go.php .. it looks up the id in the database and then goes .. but I would like to avoid forms so search engines can follow the links.

Here is the current code
note:
name="user_id" is the id of the outbound link
name="token" is a variable that is compared to a session variable to make sure the outbound link being counted is originating at my website

[code]
<form action="go.php" method="post" name="frmMyForm1297" target="_blank">
<a href="JavaScript:document.frmMyForm1297.submit();" >
<img src="../../images/illustrators/1297.jpg" alt="Catherine Lepage" width="190" height="190" border="0" /><br />
<span class="headlines"><strong> Catherine Lepage</strong></span></a>
<input type="hidden"  value="1297" name="user_id" >
<input type="hidden"  value="b3a4156b1249469af356e6bfa0483f74" name="token" >
</form>
[/code]

Ideally, I would like it to be like the following .. but I am not sure how to get it to work

[code]
<form action="go.php" method="post" name="frmMyForm1297" target="_blank">
<a href="http://www.theurl.com" onclick="outbound(1297,b3a4156b1249469af356e6bfa0483f74)">
<img src="../../images/illustrators/1297.jpg" alt="Catherine Lepage" width="190" height="190" border="0" /><br />
<span class="headlines"><strong> Catherine Lepage</strong></span></a>

[/code]
Link to comment
Share on other sites

no cause I want to avoid calling the go.php script using href .. I'd like the href to go to the url and the onclick to count the outbound link by calling the go.php

also I want to avoid using the get method cause people can easily manipulate the query string .. hence I am using the post method right now
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.