【问题标题】:How to save url that a user clicks on (PHP)如何保存用户点击的网址(PHP)
【发布时间】:2018-12-15 12:24:52
【问题描述】:

我有一个代码,人们需要输入一个地址,然后它会在下面打开。我还将 url 插入数据库以跟踪访问过的网站(如浏览历史记录)。

<?php
if($_POST){
$add=$_POST['url'];
}
?>

<...>

if (isset($_POST['history'])) {
$url = mysqli_real_escape_string($db, $_POST['url']);
$date = date('Y-m-d');
$username = $_SESSION['username'];
$query = "INSERT INTO websites (url, username, date) 
          VALUES('$url', '$username','$date')";
mysqli_query($db, $query);

  <...>
<input type="url" name="url">
<button type="submit" class="btn" name="history">Open</button>
  <...>
<iframe src="<?php echo $add; ?>" id="frame" height="800px" width="1100px" />

问题是我还需要保存用户点击其他网站内的链接时输入的网站。我如何将他们的网址保存到我的数据库中?

【问题讨论】:

    标签: php html url click


    【解决方案1】:

    这应该是不可能的,因为它只链接到给定的网站。所有点击都应在插入的 html 文档中处理,(通常是另一个服务器)(参见 https://www.w3.org/TR/html401/present/frames.html#h-16.5)。

    cURL 应该可以。在那里您可以包含 html 文档。您还可以处理 GET 和 POST 语句。来自 curl 手册:

    下载到文件: 获取网页并存储在具有特定名称的本地文件中:

        curl -o thatpage.html http://www.netscape.com/
    

    您几乎可以使用 cURL 完成所有操作。您可以在https://curl.haxx.se/docs/manual.html 找到手册

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-15
      • 1970-01-01
      • 1970-01-01
      • 2020-10-14
      • 2018-04-11
      相关资源
      最近更新 更多