如何让每个用户的时差不同?

时间:2013-10-06 12:35:33

标签: php mysql sql

在我的脚本中,我想获取登录用户的最后一个send_time。如果此send_time与当前时间至少相差10分钟,他将能够发布新内容,否则他将获得错误信息。

但是,当我尝试这个时,无人将能够发布自上一篇帖子以来至少10分钟。

$email = $_SESSION['login'];
if ($link)
 {
 $check="SELECT TIMESTAMPDIFF(MINUTE, send_time, CURRENT_TIMESTAMP) AS 'diff' FROM bloopp WHERE email = '$email' ORDER BY bloopp_id DESC LIMIT 1" or die("Error " . mysqli_error($check));
 $res = mysqli_query($link, $check) or die("Error " . mysqli_error($res));
 $data = mysqli_fetch_array($res, MYSQLI_ASSOC);
  if($data['diff'] <= "10")
   {
   echo "You posted not so long ago.";
   }
  else
   {
   $sql="INSERT INTO bloopp (bloopp, browser, medium, send_time, email) VALUES ('$bloopp', '$browser', 'desktop', NOW(), '$email')";
   $result = mysqli_query($link, $sql); 
    if($result)
     {
     header('Location: index.php');
     }
     else
     {
      echo "Something has gone wrong. We’re sorry.";
     }
    }
 }
else
 {
 echo "ERROR";
 }

0 个答案:

没有答案