如何将每个用户限制为每页一个?

时间:2016-02-08 21:51:28

标签: php

我有一个喜欢的系统,有点像facebook。但是,用户可以尽可能多地喜欢页面。如何为每个用户限制一个页面,例如每页?我的代码是:

<?php
    session_start() ;
    $conn = mysqli_connect("","","","");
    $p_id = $_GET['post_id'];
    $result = mysqli_query($conn, "SELECT * FROM forum WHERE post_id = $p_id");
    $row = mysqli_fetch_assoc($result);
    mysqli_query($conn, "UPDATE forum SET likes=likes+1 WHERE post_id = '$p_id'") ;
    ?>
    <?php
    header("Location: forum.php?id=".$row['post_id']);
    die();
    ?>

1 个答案:

答案 0 :(得分:0)

您必须跟踪该用户。用userid和postid创建一个表