Check which user clicked on which link
Question by user1295105
I have few links on my website, how can I record into database which user clicked on which link. I have records of the links into database and users. I have created a table in which there will be userid, linkid. But im not sure how to code this php. Any ideas?
EDIT:
<a hef="page.php?id=27">pagename</a>
the link above goes to a page where the link is counted and it looks for the url into the database and redirects to that page. But i want to see which user clicked it.
Answer by Starx
Most easiest way would be to pass a link-identifier
as the URI parameter
An example:
<a href="page.php?id=27&clicked=pagename">pagename</a>
Now you can get what the user clicked by checking $_GET['clicked']
It seems I misunderstood the question
You can do this on your page.php
$id = $_GET['id']; //Get the page id
$userid = $_SESSION['id']; // Get the user id if stored in session
//Do something with the user id
header("location: ..."); //redirect to a different place
exit;