0

我的网站上的链接很少,如何将哪个用户单击哪个链接记录到数据库中。我有链接到数据库和用户的记录。我创建了一个表,其中将有用户 ID、链接 ID。但我不确定如何编写这个 php。有任何想法吗?

编辑:

<a hef="page.php?id=27">pagename</a>

上面的链接转到计算链接的页面,它会在数据库中查找 url 并重定向到该页面。但我想看看哪个用户点击了它。

4

2 回答 2

1

最简单的方法是将 alink-identifier作为 URI 参数传递

一个例子:

<a href="page.php?id=27&clicked=pagename">pagename</a>

现在您可以通过检查来获取用户点击的内容$_GET['clicked']


看来我误解了这个问题

你可以在你的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;
于 2012-04-04T09:14:27.607 回答
1

http://www.google.com/例如,不要链接到,而是链接到:

redirect.php?href=http%3A%2F%2Fwww.google.com%2F

在redirect.php 中,您INSERT将记录写入数据库并执行以下操作:

 header("Location: ".$_GET['href']);
于 2012-04-04T09:18:32.823 回答